diff --git a/src/registrar/forms/application_wizard.py b/src/registrar/forms/application_wizard.py index 329cfd5e5..85320baef 100644 --- a/src/registrar/forms/application_wizard.py +++ b/src/registrar/forms/application_wizard.py @@ -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.") diff --git a/src/registrar/templates/application_sidebar.html b/src/registrar/templates/application_sidebar.html index 9f2dfffaa..be713bbe8 100644 --- a/src/registrar/templates/application_sidebar.html +++ b/src/registrar/templates/application_sidebar.html @@ -6,10 +6,10 @@ {% if forloop.counter <= wizard.steps.step1 %} - {{ this_step }} + {{ form_titles|get_item:this_step }} {% else %} - {{ this_step }} + {{ form_titles|get_item:this_step }} {% endif %} {% endfor %} diff --git a/src/registrar/templatetags/__init__.py b/src/registrar/templatetags/__init__.py new file mode 100644 index 000000000..013c5a89b --- /dev/null +++ b/src/registrar/templatetags/__init__.py @@ -0,0 +1,8 @@ +"""Custom template tags to make our lives easier.""" + +from django.template.defaulttags import register + + +@register.filter +def get_item(dictionary, key): + return dictionary.get(key) diff --git a/src/registrar/tests/test_views.py b/src/registrar/tests/test_views.py index 7372ae5d9..0c3c00b2c 100644 --- a/src/registrar/tests/test_views.py +++ b/src/registrar/tests/test_views.py @@ -90,7 +90,7 @@ class FormTests(TestWithUser, WebTest): # 302 redirect to the first form page = self.app.get(reverse("application")).follow() form = page.form - form["About your organization-organization_type"] = "Federal" + form["organization-organization_type"] = "Federal" result = page.form.submit().follow() # Got the next form page self.assertIn("contact information", result)