diff --git a/src/registrar/forms/application_wizard.py b/src/registrar/forms/application_wizard.py index b55fa62d6..7a79d0677 100644 --- a/src/registrar/forms/application_wizard.py +++ b/src/registrar/forms/application_wizard.py @@ -9,7 +9,6 @@ from django.core.validators import RegexValidator, MaxLengthValidator from django.utils.safestring import mark_safe from api.views import DOMAIN_API_MESSAGES -from registrar.management.commands.utility.terminal_helper import TerminalColors from registrar.models import Contact, DomainApplication, DraftDomain, Domain from registrar.templatetags.url_helpers import public_site_url @@ -586,24 +585,22 @@ class OtherContactsForm(RegistrarForm): error_messages={"required": "Enter a phone number for this contact."}, ) - # Override clean in order to correct validation logic def clean(self): # NOTE: using self.cleaned_data directly apparently causes a CORS error cleaned = super().clean() - form_is_empty = all(v is None or v == "" for v in cleaned.values()) - + form_is_empty = all(v is None or v == "" for v in cleaned.values()) + # NOTE: Phone number and email do NOT show up in cleaned values. # I have spent hours tyring to figure out why, but have no idea... # so for now we will grab their values from the raw data... for i in self.data: - if 'phone' in i or 'email' in i: + if "phone" in i or "email" in i: # check if it has data field_value = self.data.get(i) # update the bool on whether the form is actually empty form_is_empty = field_value == "" or field_value is None - if form_is_empty: # clear any errors raised by the form fields # (before this clean() method is run, each field @@ -616,7 +613,6 @@ class OtherContactsForm(RegistrarForm): if field in self.errors: del self.errors[field] - return cleaned diff --git a/src/registrar/tests/test_views.py b/src/registrar/tests/test_views.py index 7ae925b27..c465373dd 100644 --- a/src/registrar/tests/test_views.py +++ b/src/registrar/tests/test_views.py @@ -785,7 +785,6 @@ class DomainApplicationTests(TestWithUser, WebTest): other_contacts_form = other_contacts_page.forms[0] - # Minimal check to ensure the form is loaded with data (if this part of # the application doesn't work, we should be equipped with other unit # tests to flag it) @@ -799,7 +798,6 @@ class DomainApplicationTests(TestWithUser, WebTest): other_contacts_form["other_contacts-0-email"] = "" other_contacts_form["other_contacts-0-phone"] = "" - # Submit the now empty form result = other_contacts_form.submit() self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)