Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
rachidatecs committed Jul 29, 2024
2 parents bf031e1 + 44bd242 commit 137030e
Show file tree
Hide file tree
Showing 28 changed files with 4,598 additions and 3,740 deletions.
397 changes: 201 additions & 196 deletions src/epplibwrapper/tests/test_client.py

Large diffs are not rendered by default.

19 changes: 17 additions & 2 deletions src/registrar/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from django.http import HttpResponseRedirect
from django.shortcuts import redirect
from django_fsm import get_available_FIELD_transitions, FSMField
from registrar.models.domain_group import DomainGroup
from registrar.models.suborganization import Suborganization
from waffle.decorators import flag_is_active
from django.contrib import admin, messages
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
Expand Down Expand Up @@ -2765,6 +2767,8 @@ def save_model(self, request, obj, form, change):

class PortfolioAdmin(ListHeaderAdmin):

change_form_template = "django/admin/portfolio_change_form.html"

list_display = ("organization_name", "federal_agency", "creator")
search_fields = ["organization_name"]
search_help_text = "Search by organization name."
Expand All @@ -2775,13 +2779,25 @@ class PortfolioAdmin(ListHeaderAdmin):
"federal_agency",
]

def change_view(self, request, object_id, form_url="", extra_context=None):
"""Add related suborganizations and domain groups"""
obj = self.get_object(request, object_id)

# ---- Domain Groups
domain_groups = DomainGroup.objects.filter(portfolio=obj)

# ---- Suborganizations
suborganizations = Suborganization.objects.filter(portfolio=obj)

extra_context = {"domain_groups": domain_groups, "suborganizations": suborganizations}
return super().change_view(request, object_id, form_url, extra_context)

def save_model(self, request, obj, form, change):

if obj.creator is not None:
# ---- update creator ----
# Set the creator field to the current admin user
obj.creator = request.user if request.user.is_authenticated else None

# ---- update organization name ----
# org name will be the same as federal agency, if it is federal,
# otherwise it will be the actual org name. If nothing is entered for
Expand All @@ -2790,7 +2806,6 @@ def save_model(self, request, obj, form, change):
is_federal = obj.organization_type == DomainRequest.OrganizationChoices.FEDERAL
if is_federal and obj.organization_name is None:
obj.organization_name = obj.federal_agency.agency

super().save_model(request, obj, form, change)


Expand Down
28 changes: 28 additions & 0 deletions src/registrar/assets/js/get-gov.js
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,34 @@ function hideDeletedForms() {
});
}

// Checks for if we want to display Urbanization or not
document.addEventListener('DOMContentLoaded', function() {
var stateTerritoryField = document.querySelector('select[name="organization_contact-state_territory"]');

if (!stateTerritoryField) {
return; // Exit if the field not found
}

setupUrbanizationToggle(stateTerritoryField);
});

function setupUrbanizationToggle(stateTerritoryField) {
var urbanizationField = document.getElementById('urbanization-field');

function toggleUrbanizationField() {
// Checking specifically for Puerto Rico only
if (stateTerritoryField.value === 'PR') {
urbanizationField.style.display = 'block';
} else {
urbanizationField.style.display = 'none';
}
}

toggleUrbanizationField();

stateTerritoryField.addEventListener('change', toggleUrbanizationField);
}

/**
* An IIFE that attaches a click handler for our dynamic formsets
*
Expand Down
23 changes: 23 additions & 0 deletions src/registrar/assets/sass/_theme/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,29 @@ body {
}
}

.section--outlined__header--no-portfolio {
.section--outlined__search,
.section--outlined__utility-button {
margin-top: units(2);
}

@include at-media(tablet) {
display: flex;
column-gap: units(3);

.section--outlined__search,
.section--outlined__utility-button {
margin-top: 0;
}
.section--outlined__search {
flex-grow: 4;
// Align right
max-width: 383px;
margin-left: auto;
}
}
}

.break-word {
word-break: break-word;
}
Expand Down
11 changes: 10 additions & 1 deletion src/registrar/assets/sass/_theme/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,13 @@ a.usa-button--unstyled:visited {
box-shadow: none;
}
}


.usa-icon.usa-icon--big {
margin: 0;
height: 1.5em;
width: 1.5em;
}

.margin-right-neg-4px {
margin-right: -4px;
}
8 changes: 7 additions & 1 deletion src/registrar/config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from django.views.generic import RedirectView

from registrar import views
from registrar.views.admin_views import (
from registrar.views.report_views import (
ExportDataDomainsGrowth,
ExportDataFederal,
ExportDataFull,
Expand All @@ -19,6 +19,7 @@
ExportDataUnmanagedDomains,
AnalyticsView,
ExportDomainRequestDataFull,
ExportDataTypeUser,
)

from registrar.views.domain_request import Step
Expand Down Expand Up @@ -124,6 +125,11 @@
name="analytics",
),
path("admin/", admin.site.urls),
path(
"reports/export_data_type_user/",
ExportDataTypeUser.as_view(),
name="export_data_type_user",
),
path(
"domain-request/<id>/edit/",
views.DomainRequestWizard.as_view(),
Expand Down
11 changes: 0 additions & 11 deletions src/registrar/models/utility/generic_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,18 +170,11 @@ def _update_org_type_from_generic_org_and_election(self):
# There is no avenue for this to occur in the UI,
# as such - this can only occur if the object is initialized in this way.
# Or if there are pre-existing data.
logger.debug(
"create_or_update_organization_type() -> is_election_board "
f"cannot exist for {generic_org_type}. Setting to None."
)
self.instance.is_election_board = None
self.instance.organization_type = generic_org_type
else:
# This can only happen with manual data tinkering, which causes these to be out of sync.
if self.instance.is_election_board is None:
logger.warning(
"create_or_update_organization_type() -> is_election_board is out of sync. Updating value."
)
self.instance.is_election_board = False

if self.instance.is_election_board:
Expand Down Expand Up @@ -218,10 +211,6 @@ def _update_generic_org_and_election_from_org_type(self):
# There is no avenue for this to occur in the UI,
# as such - this can only occur if the object is initialized in this way.
# Or if there are pre-existing data.
logger.warning(
"create_or_update_organization_type() -> is_election_board "
f"cannot exist for {current_org_type}. Setting to None."
)
self.instance.is_election_board = None
else:
# if self.instance.organization_type is set to None, then this means
Expand Down
34 changes: 34 additions & 0 deletions src/registrar/templates/django/admin/portfolio_change_form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{% extends 'django/admin/email_clipboard_change_form.html' %}
{% load i18n static %}

{% block after_related_objects %}
<div class="module aligned padding-3">
<h2>Associated groups and suborganizations</h2>
<div class="grid-row grid-gap mobile:padding-x-1 desktop:padding-x-4">
<div class="mobile:grid-col-12 tablet:grid-col-6 desktop:grid-col-4">
<h3>Domain groups</h3>
<ul class="margin-0 padding-0">
{% for domain_group in domain_groups %}
<li>
<a href="{% url 'admin:registrar_domaingroup_change' domain_group.pk %}">
{{ domain_group.name }}
</a>
</li>
{% endfor %}
</ul>
</div>
<div class="mobile:grid-col-12 tablet:grid-col-6 desktop:grid-col-4">
<h3>Suborganizations</h3>
<ul class="margin-0 padding-0">
{% for suborg in suborganizations %}
<li>
<a href="{% url 'admin:registrar_suborganization_change' suborg.pk %}">
{{ suborg.name }}
</a>
</li>
{% endfor %}
</ul>
</div>
</div>
</div>
{% endblock %}
9 changes: 7 additions & 2 deletions src/registrar/templates/domain_request_org_contact.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends 'domain_request_form.html' %}
{% load field_helpers url_helpers %}
{% load field_helpers url_helpers static %}

{% block form_instructions %}
<p>If your domain request is approved, the name of your organization and your city/state will be listed in <a href="{% public_site_url 'about/data/' %}" target="_blank">.gov’s public data.</a></p>
Expand Down Expand Up @@ -37,7 +37,12 @@ <h2>What is the name and mailing address of the organization you represent?</h2>
{% input_with_errors forms.0.zipcode %}
{% endwith %}

{% input_with_errors forms.0.urbanization %}
<div id="urbanization-field" style="display: none;">
{% input_with_errors forms.0.urbanization %}
</div>

</fieldset>
{% endblock %}

<script src="{% static 'js/get-gov.js' %}" defer></script>

23 changes: 15 additions & 8 deletions src/registrar/templates/includes/domains_table.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
{% load static %}

<section class="section--outlined domains{% if portfolio is not None %} margin-top-0{% endif %}" id="domains">
<div class="grid-row">
<div class="section--outlined__header margin-bottom-3 {% if portfolio is None %} section--outlined__header--no-portfolio justify-content-space-between{% else %} grid-row{% endif %}">
<!-- Use portfolio_base_permission when merging into 2366 then delete this comment -->
{% if portfolio is None %}
<div class="mobile:grid-col-12 desktop:grid-col-6">
<h2 id="domains-header" class="flex-6">Domains</h2>
</div>
<span class="display-none" id="no-portfolio-js-flag"></span>
<h2 id="domains-header" class="display-inline-block">Domains</h2>
<span class="display-none" id="no-portfolio-js-flag"></span>
{% endif %}
<div class="mobile:grid-col-12 desktop:grid-col-6">
<section aria-label="Domains search component" class="flex-6 margin-y-2">
<div class="section--outlined__search {% if portfolio %} mobile:grid-col-12 desktop:grid-col-6{% endif %}">
<section aria-label="Domains search component" class="margin-top-2">
<form class="usa-search usa-search--small" method="POST" role="search">
{% csrf_token %}
<button class="usa-button usa-button--unstyled margin-right-3 domains__reset-search display-none" type="button">
Expand All @@ -37,10 +35,19 @@ <h2 id="domains-header" class="flex-6">Domains</h2>
</form>
</section>
</div>
<div class="section--outlined__utility-button mobile-lg:padding-right-105 {% if portfolio %} mobile:grid-col-12 desktop:grid-col-6 desktop:padding-left-3{% endif %}">
<section aria-label="Domains report component" class="mobile-lg:margin-top-205">
<a href="{% url 'export_data_type_user' %}" class="usa-button usa-button--unstyled" role="button">
<svg class="usa-icon usa-icon--big margin-right-neg-4px" aria-hidden="true" focusable="false" role="img" width="24" height="24">
<use xlink:href="{%static 'img/sprite.svg'%}#file_download"></use>
</svg>Export as CSV
</a>
</section>
</div>
</div>
<!-- Use portfolio_base_permission when merging into 2366 then delete this comment -->
{% if portfolio %}
<div class="display-flex flex-align-center margin-top-1">
<div class="display-flex flex-align-center">
<span class="margin-right-2 margin-top-neg-1 usa-prose text-base-darker">Filter by</span>
<div class="usa-accordion usa-accordion--select margin-right-2">
<div class="usa-accordion__heading">
Expand Down
Loading

0 comments on commit 137030e

Please sign in to comment.