diff --git a/src/registrar/views/application.py b/src/registrar/views/application.py index a15f36ccc..e57a5436d 100644 --- a/src/registrar/views/application.py +++ b/src/registrar/views/application.py @@ -224,8 +224,10 @@ class ApplicationWizard(ApplicationWizardPermissionView, TemplateView): if request.path_info == self.NEW_URL_NAME: return render(request, "application_intro.html") else: + logger.info('get calling self.steps.first') return self.goto(self.steps.first) + logger.info('get setting current step') self.steps.current = current_url context = self.get_context_data() context["forms"] = self.get_forms() @@ -254,6 +256,7 @@ class ApplicationWizard(ApplicationWizardPermissionView, TemplateView): All arguments (**kwargs) are passed directly to `get_forms`. """ + logger.info('get_all_forms gettig steps in self.steps') nested = (self.get_forms(step=step, **kwargs) for step in self.steps) flattened = [form for lst in nested for form in lst] return flattened @@ -269,6 +272,8 @@ class ApplicationWizard(ApplicationWizardPermissionView, TemplateView): and from the database if `use_db` is True (provided that record exists). An empty form will be provided if neither of those are true. """ + + logger.info('get_forms setting prefix to self.steps.current') kwargs = { "files": files, "prefix": self.steps.current, @@ -328,6 +333,66 @@ class ApplicationWizard(ApplicationWizardPermissionView, TemplateView): DomainApplication.ApplicationStatus.ACTION_NEEDED, ] return DomainApplication.objects.filter(creator=self.request.user, status__in=check_statuses) + + def db_check_for_unlocking_steps(self): + unlocked_steps = {} + + if self.application.organization_type: + unlocked_steps["organization_type"] = True + + if self.application.tribe_name: + unlocked_steps["tribal_government"] = True + + if self.application.federal_agency: + unlocked_steps["organization_federal"] = True + + if self.application.is_election_board: + unlocked_steps["organization_election"] = True + + if ( + self.application.organization_name + or self.application.address_line1 + or self.application.city + or self.application.state_territory + or self.application.zipcode + or self.application.urbanization + ): + unlocked_steps["organization_contact"] = True + + if self.application.about_your_organization: + unlocked_steps["about_your_organization"] = True + + if self.application.authorizing_official: + unlocked_steps["authorizing_official"] = True + + # Since this field is optional, test to see if the next step has been touched + if self.application.current_websites.exists() or self.application.requested_domain: + unlocked_steps["current_sites"] = True + + if self.application.requested_domain: + unlocked_steps["dotgov_domain"] = True + + if self.application.purpose: + unlocked_steps["purpose"] = True + + if self.application.submitter: + unlocked_steps["your_contact"] = True + + if self.application.other_contacts.exists() or self.application.no_other_contacts_rationale: + unlocked_steps["other_contacts"] = True + + # Since this field is optional, test to see if the next step has been touched + if self.application.anything_else or self.application.is_policy_acknowledged: + unlocked_steps["anything_else"] = True + + if self.application.is_policy_acknowledged: + unlocked_steps["requirements"] = True + + if self.application.submission_date: + unlocked_steps["review"] = True + + return unlocked_steps + def get_context_data(self): """Define context for access on all wizard pages.""" @@ -338,11 +403,17 @@ class ApplicationWizard(ApplicationWizardPermissionView, TemplateView): modal_heading = "You are about to submit a domain request for " + str(self.application.requested_domain) else: modal_heading = "You are about to submit an incomplete request" + + logger.info(f'get_context_data returning value for cisited equals to: {self.storage.get("step_history", [])}') + + unlocked_steps_list = list(self.db_check_for_unlocking_steps().keys()) + + return { "form_titles": self.TITLES, "steps": self.steps, # Add information about which steps should be unlocked - "visited": self.storage.get("step_history", []), + "visited": unlocked_steps_list, "is_federal": self.application.is_federal(), "modal_button": modal_button, "modal_heading": modal_heading, @@ -360,6 +431,7 @@ class ApplicationWizard(ApplicationWizardPermissionView, TemplateView): return step_list def goto(self, step): + logger.info(f'goto sets self.steps.current to passed {step}') self.steps.current = step return redirect(reverse(f"{self.URL_NAMESPACE}:{step}")) @@ -368,6 +440,7 @@ class ApplicationWizard(ApplicationWizardPermissionView, TemplateView): next = self.steps.next if next: self.steps.current = next + logger.info(f'goto sets self.goto_next_step.current to passed {self.steps.next}') return self.goto(next) else: raise Http404() @@ -387,6 +460,7 @@ class ApplicationWizard(ApplicationWizardPermissionView, TemplateView): if button == "intro_acknowledge": if request.path_info == self.NEW_URL_NAME: del self.storage + logger.info(f'post calling goto with {self.steps.first}') return self.goto(self.steps.first) # if accessing this class directly, redirect to the first step @@ -406,6 +480,7 @@ class ApplicationWizard(ApplicationWizardPermissionView, TemplateView): # return them to the page they were already on if button == "save": messages.success(request, "Your progress has been saved!") + logger.info(f'post calling goto with {self.steps.current}') return self.goto(self.steps.current) # if user opted to save progress and return, # return them to the home page diff --git a/src/registrar/views/utility/steps_helper.py b/src/registrar/views/utility/steps_helper.py index f5eca2b55..55f481263 100644 --- a/src/registrar/views/utility/steps_helper.py +++ b/src/registrar/views/utility/steps_helper.py @@ -44,28 +44,35 @@ class StepsHelper: """ def __init__(self, wizard): + logger.info(f"steps_helper __init__") self._wizard = wizard def __dir__(self): + logger.info(f"steps_helper __dir__ {self.all}") return self.all def __len__(self): + logger.info(f"steps_helper __len__ {self.count}") return self.count def __repr__(self): + logger.info(f"steps_helper __repr__ {self._wizard} {self.all}") return "" % (self._wizard, self.all) def __getitem__(self, step): + logger.info(f"steps_helper __getitem__ {self.all[step]}") return self.all[step] @property def all(self): """Returns the names of all steps.""" + logger.info(f"steps_helper all {self._wizard.get_step_list()}") return self._wizard.get_step_list() @property def count(self): """Returns the total number of steps/forms in this the wizard.""" + logger.info(f"steps_helper count {len(self.all)}") return len(self.all) @property @@ -79,12 +86,14 @@ class StepsHelper: current_url = resolve(self._wizard.request.path_info).url_name step = current_url if current_url in self.all else self.first self._wizard.storage["current_step"] = step + logger.info(f"steps_helper current getter {step}") return step @current.setter def current(self, step: str): """Sets the current step. Updates step history.""" if step in self.all: + logger.info(f"steps_helper current setter {step}") self._wizard.storage["current_step"] = step else: logger.debug("Invalid step name %s given to StepHelper" % str(step)) @@ -97,11 +106,13 @@ class StepsHelper: @property def first(self): """Returns the name of the first step.""" + logger.info(f"steps_helper first {self.all[0]}") return self.all[0] @property def last(self): """Returns the name of the last step.""" + logger.info(f"steps_helper last {self.all[-1]}") return self.all[-1] @property @@ -110,6 +121,7 @@ class StepsHelper: steps = self.all index = steps.index(self.current) + 1 if index < self.count: + logger.info(f"steps_helper next {steps[index]}") return steps[index] return None @@ -119,6 +131,7 @@ class StepsHelper: steps = self.all key = steps.index(self.current) - 1 if key >= 0: + logger.info(f"steps_helper prev {steps[key]}") return steps[key] return None @@ -127,10 +140,12 @@ class StepsHelper: """Returns the index for the current step.""" steps = self.all if self.current in steps: + logger.info(f"steps_helper index {steps.index(self)}") return steps.index(self) return None @property def history(self): """Returns the list of already visited steps.""" + logger.info(f"steps_helper history {self._wizard.storage.setdefault('step_history', [])}") return self._wizard.storage.setdefault("step_history", [])