diff --git a/src/registrar/forms/application_wizard.py b/src/registrar/forms/application_wizard.py index fcf6bda7a..1e2790214 100644 --- a/src/registrar/forms/application_wizard.py +++ b/src/registrar/forms/application_wizard.py @@ -39,9 +39,11 @@ class RegistrarForm(forms.Form): Does nothing if form is not valid. """ + logger.info(f"to_database called on {self.__class__.__name__}") if not self.is_valid(): return for name, value in self.cleaned_data.items(): + logger.info(f"{name}: {value}") setattr(obj, name, value) obj.save() @@ -547,6 +549,21 @@ class YourContactForm(RegistrarForm): ) +class OtherContactsYesNoForm(RegistrarForm): + has_other_contacts = forms.TypedChoiceField( + choices=( + (True, "Yes, I can name other employees."), + (False, "No (We'll ask you to explain why).") + ), + widget=forms.RadioSelect + ) + + def is_valid(self): + val = super().is_valid() + logger.info(f"yes no form is valid = {val}") + return val + + class OtherContactsForm(RegistrarForm): first_name = forms.CharField( label="First name / given name", diff --git a/src/registrar/models/domain_application.py b/src/registrar/models/domain_application.py index 243f029ae..417efe0e5 100644 --- a/src/registrar/models/domain_application.py +++ b/src/registrar/models/domain_application.py @@ -835,6 +835,17 @@ class DomainApplication(TimeStampedModel): """Show this step if the other contacts are blank.""" return not self.other_contacts.exists() + def has_other_contacts(self) -> bool: + """Does this application have other contacts listed?""" + return self.other_contacts.exists() + + # def __setattr__(self, name, value): + # # Check if the attribute exists in the class + # if not hasattr(self, name): + # logger.info(f"{self.__class__.__name__} object has no attribute '{name}'") + # # If the attribute exists, set its value + # super().__setattr__(name, value) + def is_federal(self) -> Union[bool, None]: """Is this application for a federal agency? diff --git a/src/registrar/templates/application_other_contacts.html b/src/registrar/templates/application_other_contacts.html index a3f0971dc..9d1873803 100644 --- a/src/registrar/templates/application_other_contacts.html +++ b/src/registrar/templates/application_other_contacts.html @@ -17,9 +17,13 @@ {% endblock %} {% block form_fields %} - {{ forms.0.management_form }} - {# forms.0 is a formset and this iterates over its forms #} - {% for form in forms.0.forms %} + + {{ forms.0 }} + {# forms.0 is a small yes/no form that toggles the visibility of "other contact" formset #} + + {{ forms.1.management_form }} + {# forms.1 is a formset and this iterates over its forms #} + {% for form in forms.1.forms %}
{% endfor %} + {% with attr_maxlength=1000 %} + {% input_with_errors forms.2.no_other_contacts_rationale %} + {% endwith %} +