mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-06-10 22:44:47 +02:00
Merge branch 'main' into nmb/field-validation
This commit is contained in:
commit
b0debba4e6
14 changed files with 521 additions and 287 deletions
|
@ -81,17 +81,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):
|
||||
|
@ -480,6 +485,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:
|
||||
|
@ -502,9 +511,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.
|
||||
|
||||
|
@ -512,16 +519,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
|
||||
|
||||
|
@ -532,7 +531,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):
|
||||
|
@ -572,7 +571,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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue