Updated step_history check to ensure side nav refreshes with correct settings

This commit is contained in:
CocoByte 2024-08-02 12:30:04 -06:00
parent bb3cfa0e2a
commit 55833f0468
No known key found for this signature in database
GPG key ID: BBFAA2526384C97F
3 changed files with 25 additions and 12 deletions

View file

@ -679,7 +679,7 @@ class CisaRepresentativeYesNoForm(BaseYesNoForm):
field_name = "has_cisa_representative" field_name = "has_cisa_representative"
class AdditionalDetailsForm(BaseDeletableRegistrarForm): class AnythingElseForm(BaseDeletableRegistrarForm):
anything_else = forms.CharField( anything_else = forms.CharField(
required=True, required=True,
label="Anything else?", label="Anything else?",
@ -698,7 +698,7 @@ class AdditionalDetailsForm(BaseDeletableRegistrarForm):
) )
class AdditionalDetailsYesNoForm(BaseYesNoForm): class AnythingElseYesNoForm(BaseYesNoForm):
"""Yes/no toggle for the anything else question on additional details""" """Yes/no toggle for the anything else question on additional details"""
# Note that these can be set as functions/init if you need more fine-grained control. # Note that these can be set as functions/init if you need more fine-grained control.

View file

@ -15,7 +15,7 @@ from registrar.forms.domain_request_wizard import (
RequirementsForm, RequirementsForm,
TribalGovernmentForm, TribalGovernmentForm,
PurposeForm, PurposeForm,
AdditionalDetailsForm, AnythingElseForm,
AboutYourOrganizationForm, AboutYourOrganizationForm,
) )
from registrar.forms.domain import ContactForm from registrar.forms.domain import ContactForm
@ -274,7 +274,7 @@ class TestFormValidation(MockEppLib):
def test_anything_else_form_about_your_organization_character_count_invalid(self): def test_anything_else_form_about_your_organization_character_count_invalid(self):
"""Response must be less than 2000 characters.""" """Response must be less than 2000 characters."""
form = AdditionalDetailsForm( form = AnythingElseForm(
data={ data={
"anything_else": "Bacon ipsum dolor amet fatback strip steak pastrami" "anything_else": "Bacon ipsum dolor amet fatback strip steak pastrami"
"shankle, drumstick doner chicken landjaeger turkey andouille." "shankle, drumstick doner chicken landjaeger turkey andouille."

View file

@ -217,6 +217,9 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
if current_url == self.EDIT_URL_NAME and "id" in kwargs: if current_url == self.EDIT_URL_NAME and "id" in kwargs:
del self.storage del self.storage
self.storage["domain_request_id"] = kwargs["id"] self.storage["domain_request_id"] = kwargs["id"]
# refresh step_history to ensure we don't erroneously unlock unfinished
# steps just because we visited it
self.storage["step_history"] = self.db_check_for_unlocking_steps() self.storage["step_history"] = self.db_check_for_unlocking_steps()
# if accessing this class directly, redirect to either to an acknowledgement # if accessing this class directly, redirect to either to an acknowledgement
@ -341,10 +344,21 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
"""Helper for get_context_data """Helper for get_context_data
Queries the DB for a domain request and returns a list of unlocked steps.""" Queries the DB for a domain request and returns a list of unlocked steps."""
# The way this works is as follows:
# Each step is assigned a true/false value to determine if it is
# "unlocked" or not. This dictionary of values is looped through
# at the end of this function and any step with a "true" value is
# added to a simple array that is returned at the end of this function.
# This array is eventually passed to the frontend context (eg. domain_request_sidebar.html),
# and is used to determine how steps appear in the side nav.
# It is worth noting that any step assigned "false" here will be EXCLUDED
# from the list of "unlocked" steps.
history_dict = { history_dict = {
"generic_org_type": self.domain_request.generic_org_type is not None, "generic_org_type": self.domain_request.generic_org_type is not None,
"tribal_government": self.domain_request.tribe_name is not None, "tribal_government": self.domain_request.tribe_name is not None,
"organization_federal": self.domain_request.federal_type is not None, "organization_federal": True,
"organization_election": self.domain_request.is_election_board is not None, "organization_election": self.domain_request.is_election_board is not None,
"organization_contact": ( "organization_contact": (
self.domain_request.federal_agency is not None self.domain_request.federal_agency is not None
@ -355,7 +369,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
or self.domain_request.zipcode is not None or self.domain_request.zipcode is not None
or self.domain_request.urbanization is not None or self.domain_request.urbanization is not None
), ),
"about_your_organization": self.domain_request.about_your_organization is not None, "about_your_organization": True,
"senior_official": self.domain_request.senior_official is not None, "senior_official": self.domain_request.senior_official is not None,
"current_sites": ( "current_sites": (
self.domain_request.current_websites.exists() or self.domain_request.requested_domain is not None self.domain_request.current_websites.exists() or self.domain_request.requested_domain is not None
@ -368,8 +382,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
or self.domain_request.no_other_contacts_rationale is not None or self.domain_request.no_other_contacts_rationale is not None
), ),
"additional_details": ( "additional_details": (
(self.domain_request.anything_else is not None and self.domain_request.has_cisa_representative) (self.domain_request.has_anything_else_text and self.domain_request.has_cisa_representative)
or self.domain_request.is_policy_acknowledged is not None
), ),
"requirements": self.domain_request.is_policy_acknowledged is not None, "requirements": self.domain_request.is_policy_acknowledged is not None,
"review": self.domain_request.is_policy_acknowledged is not None, "review": self.domain_request.is_policy_acknowledged is not None,
@ -626,8 +639,8 @@ class AdditionalDetails(DomainRequestWizard):
forms = [ forms = [
forms.CisaRepresentativeYesNoForm, forms.CisaRepresentativeYesNoForm,
forms.CisaRepresentativeForm, forms.CisaRepresentativeForm,
forms.AdditionalDetailsYesNoForm, forms.AnythingElseYesNoForm,
forms.AdditionalDetailsForm, forms.AnythingElseForm,
] ]
def is_valid(self, forms: list) -> bool: def is_valid(self, forms: list) -> bool: