diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index 6182bc828..81bb30e38 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -22,8 +22,7 @@ var SUCCESS = "success"; * */ const hideElement = (element) => { - if (element && !element.classList.contains("display-none")) - element.classList.add('display-none'); + element.classList.add('display-none'); }; /** @@ -31,8 +30,7 @@ const hideElement = (element) => { * */ const showElement = (element) => { - if (element && element.classList.contains("display-none")) - element.classList.remove('display-none'); + element.classList.remove('display-none'); }; /** diff --git a/src/registrar/forms/domain_request_wizard.py b/src/registrar/forms/domain_request_wizard.py index e6188eb33..2bc31fc37 100644 --- a/src/registrar/forms/domain_request_wizard.py +++ b/src/registrar/forms/domain_request_wizard.py @@ -27,21 +27,21 @@ class RequestingEntityForm(RegistrarForm): All of these fields are not required by default, but as we use javascript to conditionally show and hide some of these, they then become required in certain circumstances.""" - # Add a hidden field to store if the user is requesting a new suborganization + # Add a hidden field to store if the user is requesting a new suborganization. + # This hidden boolean is used for our javascript to communicate to us and to it. + # If true, the suborganization form will auto select a js value "Other". + # If this selection is made on the form (tracked by js), then it will toggle the form value of this. + # In other words, this essentially tracks if the suborganization field == "Other". + # "Other" is just an imaginary value that is otherwise invalid. + # Note the logic in `def clean` and line 2744 in get-gov.js is_requesting_new_suborganization = forms.BooleanField(required=False, widget=forms.HiddenInput()) sub_organization = forms.ModelChoiceField( label="Suborganization name", - # not required because this field won't be filled out unless - # it is a federal agency. Use clean to check programatically - # if it has been filled in when required. required=False, queryset=Suborganization.objects.none(), empty_label="--Select--", ) - - # We are using the current sub_organization naming convention here. - # We may want to refactor this to suborganization eventually. requested_suborganization = forms.CharField( label="Requested suborganization", required=False, @@ -147,7 +147,10 @@ def __init__(self, *args, **kwargs): @property def form_is_checked(self): """ - Determines the initial checked state of the form based on the domain_request's attributes. + Determines if the requesting entity is a suborganization, or a portfolio. + For suborganizations, users have the ability to request a new one if the + desired suborg doesn't exist. We expose additional fields that denote this, + like `requested_suborganization`. So we also check on those. """ if self.domain_request.requesting_entity_is_suborganization(): diff --git a/src/registrar/migrations/0135_domaininformation_requested_suborganization_and_more.py b/src/registrar/migrations/0135_domaininformation_requested_suborganization_and_more.py deleted file mode 100644 index b82619c78..000000000 --- a/src/registrar/migrations/0135_domaininformation_requested_suborganization_and_more.py +++ /dev/null @@ -1,180 +0,0 @@ -# Generated by Django 4.2.10 on 2024-10-24 16:30 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ( - "registrar", - "0134_rename_portfolio_additional_permissions_portfolioinvitation_additional_permissions_and_more", - ), - ] - - operations = [ - migrations.AddField( - model_name="domaininformation", - name="requested_suborganization", - field=models.CharField(blank=True, null=True), - ), - migrations.AddField( - model_name="domaininformation", - name="suborganization_city", - field=models.CharField(blank=True, null=True), - ), - migrations.AddField( - model_name="domaininformation", - name="suborganization_state_territory", - field=models.CharField( - blank=True, - choices=[ - ("AL", "Alabama (AL)"), - ("AK", "Alaska (AK)"), - ("AS", "American Samoa (AS)"), - ("AZ", "Arizona (AZ)"), - ("AR", "Arkansas (AR)"), - ("CA", "California (CA)"), - ("CO", "Colorado (CO)"), - ("CT", "Connecticut (CT)"), - ("DE", "Delaware (DE)"), - ("DC", "District of Columbia (DC)"), - ("FL", "Florida (FL)"), - ("GA", "Georgia (GA)"), - ("GU", "Guam (GU)"), - ("HI", "Hawaii (HI)"), - ("ID", "Idaho (ID)"), - ("IL", "Illinois (IL)"), - ("IN", "Indiana (IN)"), - ("IA", "Iowa (IA)"), - ("KS", "Kansas (KS)"), - ("KY", "Kentucky (KY)"), - ("LA", "Louisiana (LA)"), - ("ME", "Maine (ME)"), - ("MD", "Maryland (MD)"), - ("MA", "Massachusetts (MA)"), - ("MI", "Michigan (MI)"), - ("MN", "Minnesota (MN)"), - ("MS", "Mississippi (MS)"), - ("MO", "Missouri (MO)"), - ("MT", "Montana (MT)"), - ("NE", "Nebraska (NE)"), - ("NV", "Nevada (NV)"), - ("NH", "New Hampshire (NH)"), - ("NJ", "New Jersey (NJ)"), - ("NM", "New Mexico (NM)"), - ("NY", "New York (NY)"), - ("NC", "North Carolina (NC)"), - ("ND", "North Dakota (ND)"), - ("MP", "Northern Mariana Islands (MP)"), - ("OH", "Ohio (OH)"), - ("OK", "Oklahoma (OK)"), - ("OR", "Oregon (OR)"), - ("PA", "Pennsylvania (PA)"), - ("PR", "Puerto Rico (PR)"), - ("RI", "Rhode Island (RI)"), - ("SC", "South Carolina (SC)"), - ("SD", "South Dakota (SD)"), - ("TN", "Tennessee (TN)"), - ("TX", "Texas (TX)"), - ("UM", "United States Minor Outlying Islands (UM)"), - ("UT", "Utah (UT)"), - ("VT", "Vermont (VT)"), - ("VI", "Virgin Islands (VI)"), - ("VA", "Virginia (VA)"), - ("WA", "Washington (WA)"), - ("WV", "West Virginia (WV)"), - ("WI", "Wisconsin (WI)"), - ("WY", "Wyoming (WY)"), - ("AA", "Armed Forces Americas (AA)"), - ("AE", "Armed Forces Africa, Canada, Europe, Middle East (AE)"), - ("AP", "Armed Forces Pacific (AP)"), - ], - max_length=2, - null=True, - verbose_name="state, territory, or military post", - ), - ), - migrations.AddField( - model_name="domainrequest", - name="requested_suborganization", - field=models.CharField(blank=True, null=True), - ), - migrations.AddField( - model_name="domainrequest", - name="suborganization_city", - field=models.CharField(blank=True, null=True), - ), - migrations.AddField( - model_name="domainrequest", - name="suborganization_state_territory", - field=models.CharField( - blank=True, - choices=[ - ("AL", "Alabama (AL)"), - ("AK", "Alaska (AK)"), - ("AS", "American Samoa (AS)"), - ("AZ", "Arizona (AZ)"), - ("AR", "Arkansas (AR)"), - ("CA", "California (CA)"), - ("CO", "Colorado (CO)"), - ("CT", "Connecticut (CT)"), - ("DE", "Delaware (DE)"), - ("DC", "District of Columbia (DC)"), - ("FL", "Florida (FL)"), - ("GA", "Georgia (GA)"), - ("GU", "Guam (GU)"), - ("HI", "Hawaii (HI)"), - ("ID", "Idaho (ID)"), - ("IL", "Illinois (IL)"), - ("IN", "Indiana (IN)"), - ("IA", "Iowa (IA)"), - ("KS", "Kansas (KS)"), - ("KY", "Kentucky (KY)"), - ("LA", "Louisiana (LA)"), - ("ME", "Maine (ME)"), - ("MD", "Maryland (MD)"), - ("MA", "Massachusetts (MA)"), - ("MI", "Michigan (MI)"), - ("MN", "Minnesota (MN)"), - ("MS", "Mississippi (MS)"), - ("MO", "Missouri (MO)"), - ("MT", "Montana (MT)"), - ("NE", "Nebraska (NE)"), - ("NV", "Nevada (NV)"), - ("NH", "New Hampshire (NH)"), - ("NJ", "New Jersey (NJ)"), - ("NM", "New Mexico (NM)"), - ("NY", "New York (NY)"), - ("NC", "North Carolina (NC)"), - ("ND", "North Dakota (ND)"), - ("MP", "Northern Mariana Islands (MP)"), - ("OH", "Ohio (OH)"), - ("OK", "Oklahoma (OK)"), - ("OR", "Oregon (OR)"), - ("PA", "Pennsylvania (PA)"), - ("PR", "Puerto Rico (PR)"), - ("RI", "Rhode Island (RI)"), - ("SC", "South Carolina (SC)"), - ("SD", "South Dakota (SD)"), - ("TN", "Tennessee (TN)"), - ("TX", "Texas (TX)"), - ("UM", "United States Minor Outlying Islands (UM)"), - ("UT", "Utah (UT)"), - ("VT", "Vermont (VT)"), - ("VI", "Virgin Islands (VI)"), - ("VA", "Virginia (VA)"), - ("WA", "Washington (WA)"), - ("WV", "West Virginia (WV)"), - ("WI", "Wisconsin (WI)"), - ("WY", "Wyoming (WY)"), - ("AA", "Armed Forces Americas (AA)"), - ("AE", "Armed Forces Africa, Canada, Europe, Middle East (AE)"), - ("AP", "Armed Forces Pacific (AP)"), - ], - max_length=2, - null=True, - verbose_name="state, territory, or military post", - ), - ), - ] diff --git a/src/registrar/views/domain_request.py b/src/registrar/views/domain_request.py index 16ca7a69f..209a6c100 100644 --- a/src/registrar/views/domain_request.py +++ b/src/registrar/views/domain_request.py @@ -600,8 +600,6 @@ def save(self, forms: list): sub_organization = cleaned_data.get("sub_organization") requested_suborganization = cleaned_data.get("requested_suborganization") - # If no suborganization presently exists but the user filled out - # org information then create a suborg automatically. if requesting_entity_is_suborganization and (sub_organization or requested_suborganization): # Cleanup the organization name field, as this isn't for suborganizations. self.domain_request.organization_name = None