Use shorter IDs for form steps and separate sidebar titles

This commit is contained in:
Neil Martinsen-Burrell 2022-10-28 10:32:53 -05:00
parent 2f463b810b
commit f8588ebe24
No known key found for this signature in database
GPG key ID: 6A3C818CC10D0184
4 changed files with 29 additions and 10 deletions

View file

@ -49,20 +49,25 @@ class ContactForm(forms.Form):
street_address = forms.CharField(label="Street address")
ORGANIZATION_TITLE = "About your organization"
CONTACT_TITLE = "Your organization's contact information"
# List of forms in our wizard. Each entry is a tuple of a name and a form
# subclass
FORMS = [
(ORGANIZATION_TITLE, OrganizationForm),
(CONTACT_TITLE, ContactForm),
("organization", OrganizationForm),
("contact", ContactForm),
]
# Dict to match up the right template with the right step. Keys here must
# match the first elements of the tuples above
# match the first elements of the tuples in FORMS
TEMPLATES = {
ORGANIZATION_TITLE: "application_organization.html",
CONTACT_TITLE: "application_contact.html",
"organization": "application_organization.html",
"contact": "application_contact.html",
}
# We need to pass our page titles as context to the templates, indexed
# by the step names
TITLES = {
"organization": "About your organization",
"contact": "Your organization's contact information",
}
@ -85,5 +90,11 @@ class ApplicationWizard(LoginRequiredMixin, NamedUrlSessionWizardView):
"""
return [TEMPLATES[self.steps.current]]
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
return context
def done(self, form_list, **kwargs):
logger.info("Application form submitted.")