Use domain request wizard instead

This is a much better solution as we need to use this in the request experience anyway. This works towards that, but requires a bit of a refactor.
This commit is contained in:
zandercymatics 2024-09-19 15:12:29 -06:00
parent 3127f64183
commit a70d9d300d
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
7 changed files with 335 additions and 286 deletions

View file

@ -7,14 +7,14 @@ from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _
from django.views.generic import TemplateView
from django.contrib import messages
from registrar.forms import domain_request_wizard as forms
from registrar.forms.utility.wizard_form_helper import request_step_list
from registrar.models import DomainRequest
from registrar.models.contact import Contact
from registrar.models.user import User
from registrar.utility import StrEnum
from registrar.views.utility import StepsHelper
from registrar.views.utility.permission_views import DomainRequestPermissionDeleteView
from registrar.utility.enums import Step
from .utility import (
DomainRequestPermissionView,
@ -26,29 +26,6 @@ from .utility import (
logger = logging.getLogger(__name__)
class Step(StrEnum):
"""
Names for each page of the domain request wizard.
As with Django's own `TextChoices` class, steps will
appear in the order they are defined. (Order matters.)
"""
ORGANIZATION_TYPE = "generic_org_type"
TRIBAL_GOVERNMENT = "tribal_government"
ORGANIZATION_FEDERAL = "organization_federal"
ORGANIZATION_ELECTION = "organization_election"
ORGANIZATION_CONTACT = "organization_contact"
ABOUT_YOUR_ORGANIZATION = "about_your_organization"
SENIOR_OFFICIAL = "senior_official"
CURRENT_SITES = "current_sites"
DOTGOV_DOMAIN = "dotgov_domain"
PURPOSE = "purpose"
OTHER_CONTACTS = "other_contacts"
ADDITIONAL_DETAILS = "additional_details"
REQUIREMENTS = "requirements"
REVIEW = "review"
class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
"""
@ -440,15 +417,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
def get_step_list(self) -> list:
"""Dynamically generated list of steps in the form wizard."""
step_list = []
for step in Step:
condition = self.WIZARD_CONDITIONS.get(step, True)
if callable(condition):
condition = condition(self)
if condition:
step_list.append(step)
return step_list
return request_step_list(self)
def goto(self, step):
if step == "generic_org_type":
@ -530,6 +499,24 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
form.to_database(self.domain_request)
# TODO - this is a WIP until the domain request experience for portfolios is complete
class PortfolioDomainRequestWizard(DomainRequestWizard):
TITLES = {
Step.REQUESTING_ENTITY: _("Requesting entity"),
Step.CURRENT_SITES: _("Current websites"),
Step.DOTGOV_DOMAIN: _(".gov domain"),
Step.PURPOSE: _("Purpose of your domain"),
Step.ADDITIONAL_DETAILS: _("Additional details"),
Step.REQUIREMENTS: _("Requirements for operating a .gov domain"),
# Step.REVIEW: _("Review and submit your domain request"),
}
def __init__(self):
super().__init__()
self.steps = StepsHelper(self)
self._domain_request = None # for caching
class OrganizationType(DomainRequestWizard):
template_name = "domain_request_org_type.html"
forms = [forms.OrganizationTypeForm]
@ -770,6 +757,16 @@ class DomainRequestStatus(DomainRequestPermissionView):
class DomainRequestStatusViewOnly(DomainRequestPortfolioViewonlyView):
template_name = "domain_request_status_viewonly.html"
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
# Create a temp wizard object to grab the step list
wizard = PortfolioDomainRequestWizard()
wizard.request = self.request
context["Step"] = Step.__members__
context["steps"] = request_step_list(wizard)
context["form_titles"] = wizard.TITLES
return context
class DomainRequestWithdrawConfirmation(DomainRequestPermissionWithdrawView):
"""This page will ask user to confirm if they want to withdraw