From 59b8962eeec6616f15763df719d5aab5dd1bb9d8 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Wed, 24 Jul 2024 08:32:55 -0600 Subject: [PATCH] Cleanup content Move to another PR --- src/registrar/assets/js/get-gov.js | 31 -------------- src/registrar/config/urls.py | 11 ++--- src/registrar/forms/domain.py | 31 -------------- .../django/forms/widgets/combobox.html | 1 + src/registrar/templates/domain_detail.html | 4 +- src/registrar/templates/domain_sidebar.html | 7 +++- .../templates/domain_suborganization.html | 30 -------------- .../includes/domain_sidenav_item.html | 4 +- src/registrar/views/__init__.py | 1 - src/registrar/views/domain.py | 40 ------------------- 10 files changed, 19 insertions(+), 141 deletions(-) delete mode 100644 src/registrar/templates/domain_suborganization.html diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index fe4e1e356..f83966756 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -1950,34 +1950,3 @@ document.addEventListener('DOMContentLoaded', function() { showInputOnErrorFields(); })(); - -/** - * An IIFE that adds the default selection on comboboxes to the input field. - * This is because this action doesn't get fired by the time the page loads - * TODO: Will be refined in #2352 - */ -(function loadInitialValuesForComboBoxes() { - document.addEventListener('DOMContentLoaded', (event) => { - const comboBoxElements = document.querySelectorAll('.usa-combo-box'); - comboBoxElements.forEach(comboBox => { - const select = comboBox.querySelector('select'); - const input = comboBox.querySelector('input'); - - // Find the selected option - const selectedOption = select.querySelector('option[selected]'); - - // If there's a selected option, set its text as the input value. - // If the default name is "------", then this indicates that the field is blank. - // Don't populate in this case. - if (selectedOption) { - // Check to make sure the value isn't just a line of dashes. - // Caveat: we can't have any suborgs named "------". This is OK. - const isEmptyValue = /^-+$/.test(selectedOption.textContent); - if (!isEmptyValue) { - input.value = selectedOption.textContent; - comboBox.classList.add('usa-combo-box--pristine'); - } - } - }); - }); -})(); diff --git a/src/registrar/config/urls.py b/src/registrar/config/urls.py index 0af91327b..34dd72d67 100644 --- a/src/registrar/config/urls.py +++ b/src/registrar/config/urls.py @@ -182,11 +182,12 @@ urlpatterns = [ views.DomainOrgNameAddressView.as_view(), name="domain-org-name-address", ), - path( - "domain//suborganization", - views.DomainSubOrganizationView.as_view(), - name="domain-suborganization", - ), + # TODO - uncomment in #2352 + # path( + # "domain//suborganization", + # views.DomainSubOrganizationView.as_view(), + # name="domain-suborganization", + # ), path( "domain//senior-official", views.DomainSeniorOfficialView.as_view(), diff --git a/src/registrar/forms/domain.py b/src/registrar/forms/domain.py index d25fb3a7b..27752c8be 100644 --- a/src/registrar/forms/domain.py +++ b/src/registrar/forms/domain.py @@ -508,37 +508,6 @@ class DomainOrgNameAddressForm(forms.ModelForm): return old_value == new_value -# TODO: Will be refined in #2352 -class DomainSuborganizationForm(forms.ModelForm): - """Form for updating the suborganization""" - - sub_organization = forms.ModelChoiceField( - queryset=Suborganization.objects.none(), - required=True, - widget=forms.Select(), - ) - - class Meta: - model = DomainInformation - fields = [ - "sub_organization", - ] - - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - if self.instance and self.instance.portfolio: - self.fields["sub_organization"].queryset = Suborganization.objects.filter(portfolio=self.instance.portfolio) - - # Set custom form label - self.fields["sub_organization"].label = "Suborganization name" - - # Use the combobox rather than the regular select widget - self.fields["sub_organization"].widget.template_name = "django/forms/widgets/combobox.html" - - # TODO: Remove in #2352 - DomainHelper.disable_field(self.fields["sub_organization"], disable_required=True) - - class DomainDnssecForm(forms.Form): """Form for enabling and disabling dnssec""" diff --git a/src/registrar/templates/django/forms/widgets/combobox.html b/src/registrar/templates/django/forms/widgets/combobox.html index 565d35415..1330f5eee 100644 --- a/src/registrar/templates/django/forms/widgets/combobox.html +++ b/src/registrar/templates/django/forms/widgets/combobox.html @@ -1,3 +1,4 @@ +{% comment %} Will be used in #2354 {% endcomment %}
{% include "django/forms/widgets/select.html" %}
diff --git a/src/registrar/templates/domain_detail.html b/src/registrar/templates/domain_detail.html index b9e6b8039..0d129c69c 100644 --- a/src/registrar/templates/domain_detail.html +++ b/src/registrar/templates/domain_detail.html @@ -54,8 +54,10 @@ {% endif %} {% if portfolio %} + {% comment %} TODO - uncomment in #2352 and add to edit_link {% url 'domain-suborganization' pk=domain.id as url %} - {% include "includes/summary_item.html" with title='Suborganization' value=domain.domain_info.sub_organization edit_link=url editable=domain.is_editable %} + {% endcomment %} + {% include "includes/summary_item.html" with title='Suborganization' value=domain.domain_info.sub_organization edit_link="#" editable=domain.is_editable %} {% else %} {% url 'domain-org-name-address' pk=domain.id as url %} {% include "includes/summary_item.html" with title='Organization name and mailing address' value=domain.domain_info address='true' edit_link=url editable=domain.is_editable %} diff --git a/src/registrar/templates/domain_sidebar.html b/src/registrar/templates/domain_sidebar.html index 28f1c6d7d..efc863634 100644 --- a/src/registrar/templates/domain_sidebar.html +++ b/src/registrar/templates/domain_sidebar.html @@ -9,7 +9,12 @@ {% endwith %} {% if portfolio %} - {% with url_name="domain-suborganization" %} + {% comment %} TODO - uncomment in #2352 + {% with url_name="domain-suborganization" %} + {% include "includes/domain_sidenav_item.html" with item_text="Suborganization" %} + {% endwith %} + {% endcomment %} + {% with url="#" %} {% include "includes/domain_sidenav_item.html" with item_text="Suborganization" %} {% endwith %} {% else %} diff --git a/src/registrar/templates/domain_suborganization.html b/src/registrar/templates/domain_suborganization.html deleted file mode 100644 index cac0fde01..000000000 --- a/src/registrar/templates/domain_suborganization.html +++ /dev/null @@ -1,30 +0,0 @@ -{% extends "domain_base.html" %} -{% load static field_helpers%} - -{% block title %}Suborganization{% endblock %} - -{% block domain_content %} - {# this is right after the messages block in the parent template #} - {% include "includes/form_errors.html" with form=form %} - -

Organization name and mailing address

- -

- The name of your suborganization will be publicly listed as the domain registrant. - This list of suborganizations has been populated the .gov program. - If you believe there is an error please contact help@get.gov. -

- - {% if suborganization_is_editable %} - {% include "includes/required_fields.html" %} - {% endif %} - -
- {% csrf_token %} - {% input_with_errors form.sub_organization %} - {% if suborganization_is_editable %} - - {% endif %} -
- -{% endblock %} diff --git a/src/registrar/templates/includes/domain_sidenav_item.html b/src/registrar/templates/includes/domain_sidenav_item.html index 9aaff5c97..206e49c05 100644 --- a/src/registrar/templates/includes/domain_sidenav_item.html +++ b/src/registrar/templates/includes/domain_sidenav_item.html @@ -1,5 +1,7 @@
  • - {% url url_name pk=domain.id as url %} + {% if url_name %} + {% url url_name pk=domain.id as url %} + {% endif %} diff --git a/src/registrar/views/__init__.py b/src/registrar/views/__init__.py index c224e72c0..37977f334 100644 --- a/src/registrar/views/__init__.py +++ b/src/registrar/views/__init__.py @@ -3,7 +3,6 @@ from .domain import ( DomainView, DomainSeniorOfficialView, DomainOrgNameAddressView, - DomainSubOrganizationView, DomainDNSView, DomainNameserversView, DomainDNSSECView, diff --git a/src/registrar/views/domain.py b/src/registrar/views/domain.py index 3e4dee0e6..d41436aa7 100644 --- a/src/registrar/views/domain.py +++ b/src/registrar/views/domain.py @@ -16,7 +16,6 @@ from django.urls import reverse from django.views.generic.edit import FormMixin from django.conf import settings -from registrar.forms.domain import DomainSuborganizationForm from registrar.models import ( Domain, DomainRequest, @@ -27,7 +26,6 @@ from registrar.models import ( ) from registrar.models.portfolio import Portfolio from registrar.models.public_contact import PublicContact -from registrar.models.utility.domain_helper import DomainHelper from registrar.utility.enums import DefaultEmail from registrar.utility.errors import ( GenericError, @@ -224,44 +222,6 @@ class DomainOrgNameAddressView(DomainFormBaseView): return super().form_valid(form) -# TODO: Edit will be added in #2352 -class DomainSubOrganizationView(DomainFormBaseView): - """Suborganization view""" - - model = Domain - template_name = "domain_suborganization.html" - context_object_name = "domain" - form_class = DomainSuborganizationForm - - def get_form_kwargs(self, *args, **kwargs): - """Add domain_info.organization_name instance to make a bound form.""" - form_kwargs = super().get_form_kwargs(*args, **kwargs) - form_kwargs["instance"] = self.object.domain_info - return form_kwargs - - def get_success_url(self): - """Redirect to the overview page for the domain.""" - return reverse("domain-suborganization", kwargs={"pk": self.object.pk}) - - def form_valid(self, form): - """The form is valid, save the organization name and mailing address.""" - form.save() - - messages.success(self.request, "The suborganization name for this domain has been updated.") - - # superclass has the redirect - return super().form_valid(form) - - def get_context_data(self, **kwargs): - """Adds custom context.""" - context = super().get_context_data(**kwargs) - - # TODO: Switch to True #2352 - suborganization_is_editable = False - context["suborganization_is_editable"] = suborganization_is_editable - return context - - class DomainSeniorOfficialView(DomainFormBaseView): """Domain senior official editing view."""