diff --git a/src/registrar/forms/application_wizard.py b/src/registrar/forms/application_wizard.py index 0975b6810..56d62ce2b 100644 --- a/src/registrar/forms/application_wizard.py +++ b/src/registrar/forms/application_wizard.py @@ -79,17 +79,22 @@ class OrganizationContactForm(RegistrarForm): required=False, choices=DomainApplication.AGENCY_CHOICES, ) - organization_name = forms.CharField(label="Organization name") - address_line1 = forms.CharField(label="Address line 1") + organization_name = forms.CharField(label="Organization Name") + address_line1 = forms.CharField(label="Street address") address_line2 = forms.CharField( required=False, - label="Address line 2", + label="Street address line 2", ) + city = forms.CharField(label="City") state_territory = forms.ChoiceField( - label="State/territory", + label="State, territory, or military post", choices=[("", "--Select--")] + DomainApplication.StateTerritoryChoices.choices, ) zipcode = forms.CharField(label="ZIP code") + urbanization = forms.CharField( + required=False, + label="Urbanization (Puerto Rico only)", + ) class AuthorizingOfficialForm(RegistrarForm): @@ -415,6 +420,10 @@ class ApplicationWizard(LoginRequiredMixin, NamedUrlSessionWizardView): context["form_titles"] = TITLES if self.steps.current == Step.ORGANIZATION_CONTACT: context["is_federal"] = self._is_federal() + if self.steps.current == Step.REVIEW: + context["step_cls"] = Step + application = self.get_application_object() + context["application"] = application return context def get_application_object(self) -> DomainApplication: @@ -437,9 +446,7 @@ class ApplicationWizard(LoginRequiredMixin, NamedUrlSessionWizardView): self.storage.extra_data["application_id"] = application.id return application - def forms_to_database( - self, forms: dict = None, form: RegistrarForm = None - ) -> DomainApplication: + def form_to_database(self, form: RegistrarForm) -> DomainApplication: """ Unpack the form responses onto the model object properties. @@ -447,16 +454,8 @@ class ApplicationWizard(LoginRequiredMixin, NamedUrlSessionWizardView): """ application = self.get_application_object() - if forms: - itr = forms - elif form: - itr = {"form": form} - else: - raise TypeError("forms and form cannot both be None") - - for form in itr.values(): - if form is not None and hasattr(form, "to_database"): - form.to_database(application) + if form is not None and hasattr(form, "to_database"): + form.to_database(application) return application @@ -467,7 +466,7 @@ class ApplicationWizard(LoginRequiredMixin, NamedUrlSessionWizardView): Do not manipulate the form data here. """ # save progress - self.forms_to_database(form=form) + self.form_to_database(form=form) return self.get_form_step_data(form) def get_form(self, step=None, data=None, files=None): @@ -507,7 +506,7 @@ class ApplicationWizard(LoginRequiredMixin, NamedUrlSessionWizardView): def done(self, form_list, form_dict, **kwargs): """Called when the data for every form is submitted and validated.""" - application = self.forms_to_database(forms=form_dict) + application = self.get_application_object() application.submit() # change the status to submitted application.save() logger.debug("Application object saved: %s", application.id) diff --git a/src/registrar/migrations/0005_domainapplication_city_and_more.py b/src/registrar/migrations/0005_domainapplication_city_and_more.py new file mode 100644 index 000000000..ea5d6b57f --- /dev/null +++ b/src/registrar/migrations/0005_domainapplication_city_and_more.py @@ -0,0 +1,30 @@ +# Generated by Django 4.1.3 on 2022-12-12 21:00 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("registrar", "0004_domainapplication_federal_agency"), + ] + + operations = [ + migrations.AddField( + model_name="domainapplication", + name="city", + field=models.TextField(blank=True, help_text="City", null=True), + ), + migrations.AddField( + model_name="domainapplication", + name="urbanization", + field=models.TextField(blank=True, help_text="Urbanization", null=True), + ), + migrations.AlterField( + model_name="domainapplication", + name="federal_agency", + field=models.TextField( + blank=True, help_text="Top level federal agency", null=True + ), + ), + ] diff --git a/src/registrar/models/contact.py b/src/registrar/models/contact.py index 01cdcc769..6368a0101 100644 --- a/src/registrar/models/contact.py +++ b/src/registrar/models/contact.py @@ -40,9 +40,14 @@ class Contact(models.Model): db_index=True, ) + def get_formatted_name(self): + """Returns the contact's name in Western order.""" + names = [n for n in [self.first_name, self.middle_name, self.last_name] if n] + return " ".join(names) if names else "Unknown" + def __str__(self): if self.first_name or self.last_name: - return f"{self.title or ''} {self.first_name or ''} {self.last_name or ''}" + return self.get_formatted_name() elif self.email: return self.email elif self.pk: diff --git a/src/registrar/models/domain_application.py b/src/registrar/models/domain_application.py index f9332fae7..110f4fac2 100644 --- a/src/registrar/models/domain_application.py +++ b/src/registrar/models/domain_application.py @@ -28,62 +28,69 @@ class DomainApplication(TimeStampedModel): ] class StateTerritoryChoices(models.TextChoices): - ALABAMA = "AL", "Alabama" - ALASKA = "AK", "Alaska" - ARIZONA = "AZ", "Arizona" - ARKANSAS = "AR", "Arkansas" - CALIFORNIA = "CA", "California" - COLORADO = "CO", "Colorado" - CONNECTICUT = "CT", "Connecticut" - DELAWARE = "DE", "Delaware" - DISTRICT_OF_COLUMBIA = "DC", "District of Columbia" - FLORIDA = "FL", "Florida" - GEORGIA = "GA", "Georgia" - HAWAII = "HI", "Hawaii" - IDAHO = "ID", "Idaho" - ILLINOIS = "IL", "Illinois" - INDIANA = "IN", "Indiana" - IOWA = "IA", "Iowa" - KANSAS = "KS", "Kansas" - KENTUCKY = "KY", "Kentucky" - LOUISIANA = "LA", "Louisiana" - MAINE = "ME", "Maine" - MARYLAND = "MD", "Maryland" - MASSACHUSETTS = "MA", "Massachusetts" - MICHIGAN = "MI", "Michigan" - MINNESOTA = "MN", "Minnesota" - MISSISSIPPI = "MS", "Mississippi" - MISSOURI = "MO", "Missouri" - MONTANA = "MT", "Montana" - NEBRASKA = "NE", "Nebraska" - NEVADA = "NV", "Nevada" - NEW_HAMPSHIRE = "NH", "New Hampshire" - NEW_JERSEY = "NJ", "New Jersey" - NEW_MEXICO = "NM", "New Mexico" - NEW_YORK = "NY", "New York" - NORTH_CAROLINA = "NC", "North Carolina" - NORTH_DAKOTA = "ND", "North Dakota" - OHIO = "OH", "Ohio" - OKLAHOMA = "OK", "Oklahoma" - OREGON = "OR", "Oregon" - PENNSYLVANIA = "PA", "Pennsylvania" - RHODE_ISLAND = "RI", "Rhode Island" - SOUTH_CAROLINA = "SC", "South Carolina" - SOUTH_DAKOTA = "SD", "South Dakota" - TENNESSEE = "TN", "Tennessee" - TEXAS = "TX", "Texas" - UTAH = "UT", "Utah" - VERMONT = "VT", "Vermont" - VIRGINIA = "VA", "Virginia" - WASHINGTON = "WA", "Washington" - WEST_VIRGINIA = "WV", "West Virginia" - WISCONSIN = "WI", "Wisconsin" - WYOMING = "WY", "Wyoming" - AMERICAN_SAMOA = "AS", "American Samoa" - GUAM = "GU", "Guam" - NORTHERN_MARIANA_ISLANDS = "MP", "Northern Mariana Islands" - PUERTO_RICO = "PR", "Puerto Rico" - VIRGIN_ISLANDS = "VI", "Virgin Islands" + ALABAMA = "AL", "Alabama (AL)" + ALASKA = "AK", "Alaska (AK)" + AMERICAN_SAMOA = "AS", "American Samoa (AS)" + ARIZONA = "AZ", "Arizona (AZ)" + ARKANSAS = "AR", "Arkansas (AR)" + CALIFORNIA = "CA", "California (CA)" + COLORADO = "CO", "Colorado (CO)" + CONNECTICUT = "CT", "Connecticut (CT)" + DELAWARE = "DE", "Delaware (DE)" + DISTRICT_OF_COLUMBIA = "DC", "District of Columbia (DC)" + FLORIDA = "FL", "Florida (FL)" + GEORGIA = "GA", "Georgia (GA)" + GUAM = "GU", "Guam (GU)" + HAWAII = "HI", "Hawaii (HI)" + IDAHO = "ID", "Idaho (ID)" + ILLINOIS = "IL", "Illinois (IL)" + INDIANA = "IN", "Indiana (IN)" + IOWA = "IA", "Iowa (IA)" + KANSAS = "KS", "Kansas (KS)" + KENTUCKY = "KY", "Kentucky (KY)" + LOUISIANA = "LA", "Louisiana (LA)" + MAINE = "ME", "Maine (ME)" + MARYLAND = "MD", "Maryland (MD)" + MASSACHUSETTS = "MA", "Massachusetts (MA)" + MICHIGAN = "MI", "Michigan (MI)" + MINNESOTA = "MN", "Minnesota (MN)" + MISSISSIPPI = "MS", "Mississippi (MS)" + MISSOURI = "MO", "Missouri (MO)" + MONTANA = "MT", "Montana (MT)" + NEBRASKA = "NE", "Nebraska (NE)" + NEVADA = "NV", "Nevada (NV)" + NEW_HAMPSHIRE = "NH", "New Hampshire (NH)" + NEW_JERSEY = "NJ", "New Jersey (NJ)" + NEW_MEXICO = "NM", "New Mexico (NM)" + NEW_YORK = "NY", "New York (NY)" + NORTH_CAROLINA = "NC", "North Carolina (NC)" + NORTH_DAKOTA = "ND", "North Dakota (ND)" + NORTHERN_MARIANA_ISLANDS = "MP", "Northern Mariana Islands (MP)" + OHIO = "OH", "Ohio (OH)" + OKLAHOMA = "OK", "Oklahoma (OK)" + OREGON = "OR", "Oregon (OR)" + PENNSYLVANIA = "PA", "Pennsylvania (PA)" + PUERTO_RICO = "PR", "Puerto Rico (PR)" + RHODE_ISLAND = "RI", "Rhode Island (RI)" + SOUTH_CAROLINA = "SC", "South Carolina (SC)" + SOUTH_DAKOTA = "SD", "South Dakota (SD)" + TENNESSEE = "TN", "Tennessee (TN)" + TEXAS = "TX", "Texas (TX)" + UNITED_STATES_MINOR_OUTLYING_ISLANDS = ( + "UM", + "United States Minor Outlying Islands (UM)", + ) + UTAH = "UT", "Utah (UT)" + VERMONT = "VT", "Vermont (VT)" + VIRGIN_ISLANDS = "VI", "Virgin Islands (VI)" + VIRGINIA = "VA", "Virginia (VA)" + WASHINGTON = "WA", "Washington (WA)" + WEST_VIRGINIA = "WV", "West Virginia (WV)" + WISCONSIN = "WI", "Wisconsin (WI)" + WYOMING = "WY", "Wyoming (WY)" + ARMED_FORCES_AA = "AA", "Armed Forces Americas (AA)" + ARMED_FORCES_AE = "AE", "Armed Forces Africa, Canada, Europe, Middle East (AE)" + ARMED_FORCES_AP = "AP", "Armed Forces Pacific (AP)" class OrganizationChoices(models.TextChoices): FEDERAL = "federal", "Federal: a federal agency" @@ -280,7 +287,7 @@ class DomainApplication(TimeStampedModel): federal_agency = models.TextField( null=True, - blank=False, + blank=True, help_text="Top level federal agency", ) @@ -315,6 +322,11 @@ class DomainApplication(TimeStampedModel): blank=True, help_text="Address line 2", ) + city = models.TextField( + null=True, + blank=True, + help_text="City", + ) state_territory = models.CharField( max_length=2, null=True, @@ -328,6 +340,11 @@ class DomainApplication(TimeStampedModel): help_text="ZIP code", db_index=True, ) + urbanization = models.TextField( + null=True, + blank=True, + help_text="Urbanization", + ) authorizing_official = models.ForeignKey( "registrar.Contact", diff --git a/src/registrar/templates/application_org_contact.html b/src/registrar/templates/application_org_contact.html index 3d105ac50..c34dba486 100644 --- a/src/registrar/templates/application_org_contact.html +++ b/src/registrar/templates/application_org_contact.html @@ -34,10 +34,14 @@ {{ wizard.form.address_line1|add_class:"usa-input" }} {{ wizard.form.address_line2|add_label_class:"usa-label" }} {{ wizard.form.address_line2|add_class:"usa-input" }} + {{ wizard.form.city|add_label_class:"usa-label" }} + {{ wizard.form.city|add_class:"usa-input" }} {{ wizard.form.state_territory|add_label_class:"usa-label" }} {{ wizard.form.state_territory|add_class:"usa-select" }} {{ wizard.form.zipcode|add_label_class:"usa-label" }} {{ wizard.form.zipcode|add_class:"usa-input usa-input--small" }} + {{ wizard.form.urbanization|add_label_class:"usa-label" }} + {{ wizard.form.urbanization|add_class:"usa-input usa-input--small" }} diff --git a/src/registrar/templates/application_review.html b/src/registrar/templates/application_review.html index c4ac67c6e..44dd6975c 100644 --- a/src/registrar/templates/application_review.html +++ b/src/registrar/templates/application_review.html @@ -8,16 +8,87 @@ {{ wizard.management_form }} {% csrf_token %} - {% for this_step in wizard.steps.all|slice:":-1" %} -