diff --git a/src/registrar/models/domain_request.py b/src/registrar/models/domain_request.py index 0cc373f95..e3bd1c8f9 100644 --- a/src/registrar/models/domain_request.py +++ b/src/registrar/models/domain_request.py @@ -1006,22 +1006,18 @@ class DomainRequest(TimeStampedModel): def _is_additional_details_complete(self): return ( ( - (self.has_cisa_representative is True and self.cisa_representative_email is not None and self.cisa_representative_email != '') - or self.has_cisa_representative is False - ) - and - ( - - (self.has_anything_else_text is True and self.anything_else is not None and self.anything_else != '') - or self.has_anything_else_text is False - + self.has_cisa_representative is True + and self.cisa_representative_email is not None + and self.cisa_representative_email != "" ) + or self.has_cisa_representative is False + ) and ( + (self.has_anything_else_text is True and self.anything_else is not None and self.anything_else != "") + or self.has_anything_else_text is False ) - - # def _is_policy_acknoledgment_complete(self): - # return ( - # ) + def _is_policy_acknowledgement_complete(self): + return self.is_policy_acknowledged is not None def _is_general_form_complete(self): return ( @@ -1032,6 +1028,7 @@ class DomainRequest(TimeStampedModel): and self._is_submitter_complete() and self._is_other_contacts_complete() and self._is_additional_details_complete() + and self._is_policy_acknowledgement_complete() ) def _form_complete(self): diff --git a/src/registrar/tests/test_models.py b/src/registrar/tests/test_models.py index 9c03e46cb..d26f49ee9 100644 --- a/src/registrar/tests/test_models.py +++ b/src/registrar/tests/test_models.py @@ -1657,7 +1657,7 @@ class TestDomainRequestIncomplete(TestCase): submitter=you, has_cisa_representative=False, has_anything_else_text=True, - anything_else='else', + anything_else="Anything else", is_policy_acknowledged=True, creator=self.user, ) @@ -1670,15 +1670,8 @@ class TestDomainRequestIncomplete(TestCase): super().tearDown() DomainRequest.objects.all().delete() Contact.objects.all().delete() - # Domain.objects.all().delete() - # DomainInformation.objects.all().delete() - # User.objects.all().delete() - # DraftDomain.objects.all().delete() def test_is_federal_complete(self): - # self.domain_request.generic_org_type = DomainRequest.OrganizationChoices.FEDERAL - # federal_type="executive", - # federal_agency=FederalAgency.objects.get(agency="AMTRAK"), self.assertTrue(self.domain_request._is_federal_complete()) self.domain_request.federal_type = None self.domain_request.save() @@ -1734,7 +1727,7 @@ class TestDomainRequestIncomplete(TestCase): self.domain_request.is_election_board = None self.domain_request.save() self.domain_request.refresh_from_db() - print(f'self.domain_request.is_election_board {self.domain_request.is_election_board }') + print(f"self.domain_request.is_election_board {self.domain_request.is_election_board }") self.assertFalse(self.domain_request._is_city_complete()) def test_is_special_district_complete(self): @@ -1748,6 +1741,7 @@ class TestDomainRequestIncomplete(TestCase): self.domain_request.save() self.assertFalse(self.domain_request._is_special_district_complete()) + # TODO: Fix def test_is_organization_name_and_address_complete(self): self.assertTrue(self.domain_request._is_organization_name_and_address_complete()) self.domain_request.organization_name = None @@ -1791,42 +1785,98 @@ class TestDomainRequestIncomplete(TestCase): self.assertFalse(self.domain_request._is_other_contacts_complete()) def test_is_additional_details_complete(self): - # Initial setup - self.domain_request.has_cisa_representative = False - self.domain_request.has_anything_else_text = True - self.domain_request.anything_else = "Some text" - self.domain_request.save() - # anything else checked, anything else filled in, and cisa rep checked false + # CISA Rep - No, Anything Else Radio - Anything Else Text - Filled self.assertTrue(self.domain_request._is_additional_details_complete()) - # Set cisa rep to True and provide an email + # CISA Rep - No, Anything Else Radio - No + self.domain_request.has_anything_else_text = False + self.assertTrue(self.domain_request._is_additional_details_complete()) + + # CISA Rep - Yes, CISA Rep Email - Yes (And has above Anything Else Radio - No) self.domain_request.has_cisa_representative = True self.domain_request.cisa_representative_email = "some@cisarepemail.com" self.domain_request.save() - - # has anything else, cisa rep checked true, has rep email self.assertTrue(self.domain_request._is_additional_details_complete()) - # Set cisa rep to None + # CISA Rep - None, CISA Rep Email - None, Anything Else Radio - No self.domain_request.cisa_representative_email = None self.domain_request.has_cisa_representative = None self.domain_request.save() - - # Check immediately after saving - print("After setting to None and saving:") - print(f'has_cisa_representative (before refresh): {self.domain_request.has_cisa_representative}') + self.assertFalse(self.domain_request._is_additional_details_complete()) # Refresh from the database self.domain_request.refresh_from_db() - # Check after refreshing from the database - print("After refreshing from DB:") - print(f'has_cisa_representative (after refresh): {self.domain_request.has_cisa_representative}') + # # Check immediately after saving + print("After setting to None and saving:") + print(f"has_cisa_representative (before refresh): {self.domain_request.has_cisa_representative}") + print(f"cisa_representative_email (before refresh): {self.domain_request.cisa_representative_email}") + print(f"has_anything_else_text (before refresh): {self.domain_request.has_anything_else_text}") + print(f"anything_else (before refresh): {self.domain_request.anything_else}") + # TODO: Get help + # CISA Rep - Yes, CISA Rep Email - Yes, Anything Else Radio - Yes, Anything Else Text - No + self.domain_request.has_cisa_representative = True + self.domain_request.cisa_representative_email = "some@cisarepemail.com" + # If you choose yes on radio button but dont have text it should error + self.domain_request.has_anything_else_text = True + self.domain_request.anything_else = None + self.domain_request.save() + + print("After setting to None and saving:") + print(f"has_cisa_representative (after refresh): {self.domain_request.has_cisa_representative}") + print(f"cisa_representative_email (after refresh): {self.domain_request.cisa_representative_email}") + print(f"has_anything_else_text (after refresh): {self.domain_request.has_anything_else_text}") + print(f"anything_else (after refresh): {self.domain_request.anything_else}") + # has_cisa_representative (after refresh): True + # cisa_representative_email (after refresh): some@cisarepemail.com + # has_anything_else_text (after refresh): False + # anything_else (after refresh): None + + # # This ensures that if we have prefilled data, the form is prepopulated + # if self.cisa_representative_email is not None: + # self.has_cisa_representative = self.cisa_representative_email != "" + + # # 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_email != "" and self.cisa_representative_email is not None + # ) + + # # This ensures that if we have prefilled data, the form is prepopulated + # if self.anything_else is not None: + # self.has_anything_else_text = self.anything_else != "" + + # # This check is required to ensure that the form doesn't start out checked. + # if self.has_anything_else_text is not None: + # self.has_anything_else_text = self.anything_else != "" and self.anything_else is not None + + self.assertFalse(self.domain_request._is_additional_details_complete()) + + self.domain_request.anything_else = "Some text here" + self.domain_request.save() + self.assertFalse(self.domain_request._is_additional_details_complete()) + + # # Check immediately after saving + # print("After setting to None and saving:") + # print(f'has_cisa_representative (before refresh): {self.domain_request.has_cisa_representative}') + + # Refresh from the database + # self.domain_request.refresh_from_db() + + # # Check after refreshing from the database + # print("After refreshing from DB:") + # print(f'has_cisa_representative (after refresh): {self.domain_request.has_cisa_representative}') # Expect False because has_cisa_representative is None (which we now explicitly handle) - self.assertFalse(self.domain_request._is_additional_details_complete()) + + def test_is_policy_acknowledgement_complete(self): + self.assertTrue(self.domain_request._is_policy_acknowledgement_complete()) + self.domain_request.is_policy_acknowledged = False + self.assertTrue(self.domain_request._is_policy_acknowledgement_complete()) + self.domain_request.is_policy_acknowledged = None + self.assertFalse(self.domain_request._is_policy_acknowledgement_complete()) def test_is_general_form_complete(self): self.assertTrue(self.domain_request._is_general_form_complete()) diff --git a/src/registrar/tests/test_views_request.py b/src/registrar/tests/test_views_request.py index faa6afd68..d1ad07ebb 100644 --- a/src/registrar/tests/test_views_request.py +++ b/src/registrar/tests/test_views_request.py @@ -475,7 +475,7 @@ class DomainRequestTests(TestWithUser, WebTest): num_pages_tested = 0 # elections, type_of_work, tribal_government SKIPPED_PAGES = 3 - num_pages = len(self.TITLES) - SKIPPED_PAGES + # num_pages = len(self.TITLES) - SKIPPED_PAGES intro_page = self.app.get(reverse("domain-request:")) # django-webtest does not handle cookie-based sessions well because it keeps @@ -748,16 +748,12 @@ class DomainRequestTests(TestWithUser, WebTest): requirements_form["requirements-is_policy_acknowledged"] = True - # Before we go to the review page, let's remove some of the data from the request: domain_request = DomainRequest.objects.get() # there's only one domain_request.generic_org_type = None domain_request.save() - - - # test next button self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id) requirements_result = requirements_form.submit() @@ -793,8 +789,7 @@ class DomainRequestTests(TestWithUser, WebTest): self.assertNotContains(review_page, "You are about to submit a domain request for city.gov") self.assertContains(review_page, "You can’t submit this request because it’s incomplete.") - - # DO WE NEED TO BLOCK SUBMISSIONS WITH INCIMPLETE FORMS ON THE BACKEND @Alysia? + # DO WE NEED TO BLOCK SUBMISSIONS WITH INCOMPLETE FORMS ON THE BACKEND @Alysia? # final submission results in a redirect to the "finished" URL # self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id) diff --git a/src/registrar/views/domain_request.py b/src/registrar/views/domain_request.py index 7e864987d..7e8f9e1d4 100644 --- a/src/registrar/views/domain_request.py +++ b/src/registrar/views/domain_request.py @@ -374,110 +374,6 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView): } return [key for key, value in history_dict.items() if value] - # def _is_federal_complete(self): - # # Federal -> "Federal government branch" page can't be empty + Federal Agency selection can't be None - # return not (self.domain_request.federal_type is None or self.domain_request.federal_agency is None) - - # def _is_interstate_complete(self): - # # Interstate -> "About your organization" page can't be empty - # return self.domain_request.about_your_organization is not None - - # def _is_state_or_territory_complete(self): - # # State -> ""Election office" page can't be empty - # return self.domain_request.is_election_board is not None - - # def _is_tribal_complete(self): - # # Tribal -> "Tribal name" and "Election office" page can't be empty - # return self.domain_request.tribe_name is not None and self.domain_request.is_election_board is not None - - # def _is_county_complete(self): - # # County -> "Election office" page can't be empty - # return self.domain_request.is_election_board is not None - - # def _is_city_complete(self): - # # City -> "Election office" page can't be empty - # return self.domain_request.is_election_board is not None - - # def _is_special_district_complete(self): - # # Special District -> "Election office" and "About your organization" page can't be empty - # return ( - # self.domain_request.is_election_board is not None - # and self.domain_request.about_your_organization is not None - # ) - - # def _is_organization_name_and_address_complete(self): - # return not ( - # self.domain_request.organization_name is None - # or self.domain_request.address_line1 is None - # or self.domain_request.city is None - # or self.domain_request.state_territory is None - # or self.domain_request.zipcode is None - # ) - - # def _is_authorizing_official_complete(self): - # return self.domain_request.authorizing_official is not None - - # def _is_requested_domain_complete(self): - # return self.domain_request.requested_domain is not None - - # def _is_purpose_complete(self): - # return self.domain_request.purpose is not None - - # def _is_submitter_complete(self): - # return self.domain_request.submitter is not None - - # def _is_other_contacts_complete(self): - # return self.domain_request.other_contacts is not None - - # def _is_additional_details_complete(self): - # return not ( - # self.domain_request.has_cisa_representative is None - # or self.domain_request.has_anything_else_text is None - # # RARE EDGE CASE: You click yes on having a cisa rep, but you dont type in email (should block in form) - # or ( - # self.domain_request.has_cisa_representative is True - # and self.domain_request.cisa_representative_email is None - # ) - # or self.domain_request.is_policy_acknowledged is None - # ) - - # def _is_general_form_complete(self): - # return ( - # self._is_organization_name_and_address_complete() - # and self._is_authorizing_official_complete() - # and self._is_requested_domain_complete() - # and self._is_purpose_complete() - # and self._is_submitter_complete() - # and self._is_other_contacts_complete() - # and self._is_additional_details_complete() - # ) - - # def _form_complete(self): - # if self.domain_request.generic_org_type == DomainRequest.OrganizationChoices.FEDERAL: - # is_complete = self._is_federal_complete() - # elif self.domain_request.generic_org_type == DomainRequest.OrganizationChoices.INTERSTATE: - # is_complete = self._is_interstate_complete() - # elif self.domain_request.generic_org_type == DomainRequest.OrganizationChoices.STATE_OR_TERRITORY: - # is_complete = self._is_state_or_territory_complete() - # elif self.domain_request.generic_org_type == DomainRequest.OrganizationChoices.TRIBAL: - # is_complete = self._is_tribal_complete() - # elif self.domain_request.generic_org_type == DomainRequest.OrganizationChoices.COUNTY: - # is_complete = self._is_county_complete() - # elif self.domain_request.generic_org_type == DomainRequest.OrganizationChoices.CITY: - # is_complete = self._is_city_complete() - # elif self.domain_request.generic_org_type == DomainRequest.OrganizationChoices.SPECIAL_DISTRICT: - # is_complete = self._is_special_district_complete() - # else: - # # NOTE: This shouldn't happen, this is only if somehow they didn't choose an org type - # is_complete = False - - # if not is_complete or not self._is_general_form_complete(): - # print("!!!! We are in the False if statement - form is not complete") - # return False - - # print("!!!! We are in the True if statement - form is complete") - # return True - def get_context_data(self): """Define context for access on all wizard pages.""" # Build the submit button that we'll pass to the modal.