diff --git a/src/registrar/models/domain_request.py b/src/registrar/models/domain_request.py index 4bf683c2f..a9b63362e 100644 --- a/src/registrar/models/domain_request.py +++ b/src/registrar/models/domain_request.py @@ -557,14 +557,15 @@ class DomainRequest(TimeStampedModel): # This ensures that if we have prefilled data, the form is prepopulated if self.cisa_representative_first_name is not None or self.cisa_representative_last_name is not None: - self.has_cisa_representative = self.cisa_representative_first_name != "" and self.cisa_representative_last_name != "" - + self.has_cisa_representative = ( + self.cisa_representative_first_name != "" and self.cisa_representative_last_name != "" + ) + # This check is required to ensure that the form doesn't start out checked if self.has_cisa_representative is not None: self.has_cisa_representative = ( - (self.cisa_representative_first_name != "" and self.cisa_representative_first_name is not None) - and (self.cisa_representative_last_name != "" and self.cisa_representative_last_name is not None) - ) + self.cisa_representative_first_name != "" and self.cisa_representative_first_name is not None + ) and (self.cisa_representative_last_name != "" and self.cisa_representative_last_name is not None) # This ensures that if we have prefilled data, the form is prepopulated if self.anything_else is not None: @@ -1033,7 +1034,8 @@ class DomainRequest(TimeStampedModel): return False def _cisa_rep_check(self): - # Either does not have a CISA rep, OR has a CISA rep + both first name and last name are NOT empty and are NOT an empty string + # Either does not have a CISA rep, OR has a CISA rep + both first name + # and last name are NOT empty and are NOT an empty string return ( self.has_cisa_representative is True and self.cisa_representative_first_name is not None diff --git a/src/registrar/tests/test_models.py b/src/registrar/tests/test_models.py index 2102c7665..b0de31304 100644 --- a/src/registrar/tests/test_models.py +++ b/src/registrar/tests/test_models.py @@ -1884,7 +1884,7 @@ class TestDomainRequestIncomplete(TestCase): # therefore, our expected will be True { "has_cisa_representative": True, - # Above will be overridden to False if cisa_representative_first_name is None bc of sync_yes_no_form_fields + # Above will be overridden to False if cisa_representative_first_name is None "cisa_representative_first_name": None, "cisa_representative_last_name": None, "cisa_representative_email": None, @@ -1898,8 +1898,8 @@ class TestDomainRequestIncomplete(TestCase): # Email - None # Anything Else Radio - Yes # Anything Else Text - None - # NOTE: We should never have an instance where only firstname or only lastname are populated (they are both required) - # However, if this happens, the application will default to False for has_cisa_representative + # NOTE: We should never have an instance where only firstname or only lastname are populated + # (they are both required) { "has_cisa_representative": True, # Above will be overridden to False if cisa_representative_first_name is None or