diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index 81bb30e38..be658ad3e 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -2789,7 +2789,6 @@ document.addEventListener('DOMContentLoaded', function() { subOrgSelect.add(fakeOption); } - console.log(isRequestingSuborganization.value) if (isRequestingSuborganization.value === "True") { subOrgSelect.value = "other" } diff --git a/src/registrar/forms/domain_request_wizard.py b/src/registrar/forms/domain_request_wizard.py index 2bc31fc37..b27a004c0 100644 --- a/src/registrar/forms/domain_request_wizard.py +++ b/src/registrar/forms/domain_request_wizard.py @@ -111,7 +111,9 @@ def clean(self): # Get the value of the yes/no checkbox from RequestingEntityYesNoForm. # Since self.data stores this as a string, we need to convert "True" => True. - requesting_entity_is_suborganization = self.data.get("portfolio_requesting_entity-requesting_entity_is_suborganization") + requesting_entity_is_suborganization = self.data.get( + "portfolio_requesting_entity-requesting_entity_is_suborganization" + ) if requesting_entity_is_suborganization == "True": if is_requesting_new_suborganization: # Validate custom suborganization fields diff --git a/src/registrar/tests/test_views_portfolio.py b/src/registrar/tests/test_views_portfolio.py index 1ca2d2bcd..45357cbf7 100644 --- a/src/registrar/tests/test_views_portfolio.py +++ b/src/registrar/tests/test_views_portfolio.py @@ -1717,7 +1717,6 @@ def test_requesting_entity_page_new_suborg_submission(self): self.assertContains(response, "Who will use the domain you’re requesting?") form = response.forms[0] - # Test selecting an existing suborg form["portfolio_requesting_entity-requesting_entity_is_suborganization"] = True form["portfolio_requesting_entity-is_requesting_new_suborganization"] = True form["portfolio_requesting_entity-sub_organization"] = "" diff --git a/src/registrar/views/domain_request.py b/src/registrar/views/domain_request.py index 209a6c100..7fb2d9b16 100644 --- a/src/registrar/views/domain_request.py +++ b/src/registrar/views/domain_request.py @@ -594,25 +594,32 @@ def save(self, forms: list): """Override of save to clear or associate certain suborganization data depending on what the user wishes to do. For instance, we want to add a suborganization if the user selects one.""" + yesno_form = forms[0] requesting_entity_form = forms[1] + + yesno_cleaned_data = yesno_form.cleaned_data + requesting_entity_is_suborganization = yesno_cleaned_data.get("requesting_entity_is_suborganization") + cleaned_data = requesting_entity_form.cleaned_data - requesting_entity_is_suborganization = cleaned_data.get("requesting_entity_is_suborganization") sub_organization = cleaned_data.get("sub_organization") requested_suborganization = cleaned_data.get("requested_suborganization") 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 - self.domain_request.sub_organization = sub_organization + requesting_entity_form.cleaned_data.update({"organization_name": None}) else: # If the user doesn't intend to create a suborg, simply don't make one and do some data cleanup - if self.domain_request.portfolio: - self.domain_request.organization_name = self.domain_request.portfolio.organization_name - - self.domain_request.sub_organization = None - self.domain_request.requested_suborganization = None - self.domain_request.suborganization_city = None - self.domain_request.suborganization_state_territory = None + requesting_entity_form.cleaned_data.update( + { + "organization_name": ( + self.domain_request.portfolio.organization_name if self.domain_request.portfolio else None + ), + "sub_organization": None, + "requested_suborganization": None, + "suborganization_city": None, + "suborganization_state_territory": None, + } + ) super().save(forms)