From c5e406c4005676c98c84e9ba829af10d9765a2a5 Mon Sep 17 00:00:00 2001 From: Neil Martinsen-Burrell Date: Tue, 29 Nov 2022 15:27:56 -0600 Subject: [PATCH] Add a combo box only for federal agencies --- src/registrar/forms/application_wizard.py | 40 +++++++++-- src/registrar/models/domain_application.py | 10 ++- .../templates/application_org_contact.html | 8 ++- .../templates/application_org_type.html | 14 ++-- .../includes/organization_federal.html | 72 +++++++++++++++++++ .../includes/organization_nonfederal.html | 4 ++ 6 files changed, 130 insertions(+), 18 deletions(-) create mode 100644 src/registrar/templates/includes/organization_federal.html create mode 100644 src/registrar/templates/includes/organization_nonfederal.html diff --git a/src/registrar/forms/application_wizard.py b/src/registrar/forms/application_wizard.py index 7c57cb20d..77a8711d5 100644 --- a/src/registrar/forms/application_wizard.py +++ b/src/registrar/forms/application_wizard.py @@ -28,10 +28,10 @@ class OrganizationTypeForm(RegistrarForm): organization_type = forms.ChoiceField( required=True, choices=[ - ("Federal", "Federal: a federal agency"), - ("Interstate", "Interstate: an organization of two or more states"), + (DomainApplication.FEDERAL, "Federal: a federal agency"), + (DomainApplication.INTERSTATE, "Interstate: an organization of two or more states"), ( - "State_or_Territory", + DomainApplication.STATE_OR_TERRITORY, ( "State or Territory: One of the 50 U.S. states, the District of " "Columbia, American Samoa, Guam, Northern Mariana Islands, " @@ -39,16 +39,16 @@ class OrganizationTypeForm(RegistrarForm): ), ), ( - "Tribal", + DomainApplication.TRIBAL, ( "Tribal: a tribal government recognized by the federal or " "state government" ), ), - ("County", "County: a county, parish, or borough"), - ("City", "City: a city, town, township, village, etc."), + (DomainApplication.COUNTY, "County: a county, parish, or borough"), + (DomainApplication.CITY, "City: a city, town, township, village, etc."), ( - "Special_District", + DomainApplication.SPECIAL_DISTRICT, "Special District: an independent organization within a single state", ), ], @@ -314,10 +314,36 @@ class ApplicationWizard(LoginRequiredMixin, NamedUrlSessionWizardView): """ return [TEMPLATES[self.steps.current]] + def _is_federal(self) -> bool: + """Return whether this application is from a federal agency. + + Returns True if we know that this application is from a federal + agency, False if we know that it is not and None if there isn't an + answer yet for that question. + """ + organization_type_data = self.get_cleaned_data_for_step("organization_type") + if organization_type_data is None: + return None # no answers here yet + organization_type = organization_type_data.get("organization_type") + print(organization_type) + if organization_type is None: + # they haven't answered this question + print("No organization type: returning None") + return None + else: + # they have answered this question + if organization_type == DomainApplication.FEDERAL: + print("organization type is federal: returning true") + return True + print("organization type is not federal: returning false") + return False + def get_context_data(self, form, **kwargs): """Add title information to the context for all steps.""" context = super().get_context_data(form=form, **kwargs) context["form_titles"] = TITLES + if self.steps.current == "organization_contact": + context["is_federal"] = self._is_federal() return context def forms_to_object(self, form_dict: dict) -> DomainApplication: diff --git a/src/registrar/models/domain_application.py b/src/registrar/models/domain_application.py index ff34b4cb9..008b4d43e 100644 --- a/src/registrar/models/domain_application.py +++ b/src/registrar/models/domain_application.py @@ -253,7 +253,10 @@ class DomainApplication(TimeStampedModel): @staticmethod def show_organization_federal(wizard: ApplicationWizard) -> bool: """Show this step if the answer to the first question was "federal".""" - return DomainApplication._get_organization_type(wizard) == "Federal" + return ( + DomainApplication._get_organization_type(wizard) + == DomainApplication.FEDERAL + ) @staticmethod def show_organization_election(wizard: ApplicationWizard) -> bool: @@ -262,6 +265,9 @@ class DomainApplication(TimeStampedModel): This shows for answers that aren't "Federal" or "Interstate". """ type_answer = DomainApplication._get_organization_type(wizard) - if type_answer and type_answer not in ("Federal", "Interstate"): + if type_answer and type_answer not in ( + DomainApplication.FEDERAL, + DomainApplication.INTERSTATE, + ): return True return False diff --git a/src/registrar/templates/application_org_contact.html b/src/registrar/templates/application_org_contact.html index a879bd126..3bd28a763 100644 --- a/src/registrar/templates/application_org_contact.html +++ b/src/registrar/templates/application_org_contact.html @@ -22,8 +22,12 @@
What is the name and mailing address of your organization? - {{ wizard.form.organization_name|add_label_class:"usa-label" }} - {{ wizard.form.organization_name|add_class:"usa-input" }} + + {% if is_federal %} + {% include 'includes/organization_federal.html' %} + {% else %} + {% include 'includes/organization_nonfederal.html' %} + {% endif %} {{ wizard.form.address_line1|add_label_class:"usa-label" }} {{ wizard.form.address_line1|add_class:"usa-input" }} {{ wizard.form.address_line2|add_label_class:"usa-label" }} diff --git a/src/registrar/templates/application_org_type.html b/src/registrar/templates/application_org_type.html index de399e5c3..089f0b329 100644 --- a/src/registrar/templates/application_org_type.html +++ b/src/registrar/templates/application_org_type.html @@ -16,13 +16,13 @@

What kind of government organization do you represent?

{{ wizard.form.organization_type.errors }} - {% include "includes/radio_button.html" with choice=choices.Federal tile="true" %} - {% include "includes/radio_button.html" with choice=choices.Interstate tile="true" %} - {% include "includes/radio_button.html" with choice=choices.State_or_Territory tile="true" %} - {% include "includes/radio_button.html" with choice=choices.Tribal tile="true" %} - {% include "includes/radio_button.html" with choice=choices.County tile="true" %} - {% include "includes/radio_button.html" with choice=choices.City tile="true" %} - {% include "includes/radio_button.html" with choice=choices.Special_District tile="true" %} + {% include "includes/radio_button.html" with choice=choices.federal tile="true" %} + {% include "includes/radio_button.html" with choice=choices.interstate tile="true" %} + {% include "includes/radio_button.html" with choice=choices.state_or_territory tile="true" %} + {% include "includes/radio_button.html" with choice=choices.tribal tile="true" %} + {% include "includes/radio_button.html" with choice=choices.county tile="true" %} + {% include "includes/radio_button.html" with choice=choices.city tile="true" %} + {% include "includes/radio_button.html" with choice=choices.special_district tile="true" %}
{{ block.super }} diff --git a/src/registrar/templates/includes/organization_federal.html b/src/registrar/templates/includes/organization_federal.html new file mode 100644 index 000000000..326f08f0b --- /dev/null +++ b/src/registrar/templates/includes/organization_federal.html @@ -0,0 +1,72 @@ +{% load widget_tweaks %} + +{{ wizard.form.organization_name|add_label_class:"usa-label" }} +
+ +
diff --git a/src/registrar/templates/includes/organization_nonfederal.html b/src/registrar/templates/includes/organization_nonfederal.html new file mode 100644 index 000000000..04bd99886 --- /dev/null +++ b/src/registrar/templates/includes/organization_nonfederal.html @@ -0,0 +1,4 @@ +{% load widget_tweaks %} + +{{ wizard.form.organization_name|add_label_class:"usa-label" }} +{{ wizard.form.organization_name|add_class:"usa-input" }}