From a70d9d300d298acca8ac7297ccba26eab310c69d Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Thu, 19 Sep 2024 15:12:29 -0600 Subject: [PATCH] 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. --- .../forms/utility/wizard_form_helper.py | 15 +- .../templates/domain_request_review.html | 184 +----------------- .../includes/domain_request_review_steps.html | 168 ++++++++++++++++ .../includes/domain_request_status_view.html | 72 +------ ...portfolio_domain_request_review_steps.html | 86 ++++++++ src/registrar/utility/enums.py | 31 ++- src/registrar/views/domain_request.py | 65 +++---- 7 files changed, 335 insertions(+), 286 deletions(-) create mode 100644 src/registrar/templates/includes/domain_request_review_steps.html create mode 100644 src/registrar/templates/includes/portfolio_domain_request_review_steps.html diff --git a/src/registrar/forms/utility/wizard_form_helper.py b/src/registrar/forms/utility/wizard_form_helper.py index 2ae50f908..e1f7cf94c 100644 --- a/src/registrar/forms/utility/wizard_form_helper.py +++ b/src/registrar/forms/utility/wizard_form_helper.py @@ -4,7 +4,7 @@ from itertools import zip_longest from typing import Callable from django.db.models.fields.related import ForeignObjectRel from django import forms - +from registrar.utility.enums import Step from registrar.models import DomainRequest, Contact @@ -278,3 +278,16 @@ class BaseYesNoForm(RegistrarForm): # No pre-selection for new domain requests initial_value = self.form_is_checked if self.domain_request else None return initial_value + + +def request_step_list(request_wizard): + """Dynamically generated list of steps in the form wizard.""" + step_list = [] + for step in Step: + condition = request_wizard.WIZARD_CONDITIONS.get(step, True) + if callable(condition): + condition = condition(request_wizard) + if condition: + step_list.append(step) + return step_list + diff --git a/src/registrar/templates/domain_request_review.html b/src/registrar/templates/domain_request_review.html index ced20b6b7..f664a3c90 100644 --- a/src/registrar/templates/domain_request_review.html +++ b/src/registrar/templates/domain_request_review.html @@ -19,183 +19,9 @@ {% endblock %} {% block form_fields %} - {% for step in steps.all|slice:":-1" %} -
- - {% if step == Step.ORGANIZATION_TYPE %} - {% namespaced_url 'domain-request' step as domain_request_url %} - {% if domain_request.generic_org_type is not None %} - {% with title=form_titles|get_item:step value=domain_request.get_generic_org_type_display|default:"Incomplete"|safe %} - {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=domain_request_url %} - {% endwith %} - {% else %} - {% with title=form_titles|get_item:step value="Incomplete"|safe %} - {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=domain_request_url %} - {% endwith %} - {% endif %} - {% endif %} - - {% if step == Step.TRIBAL_GOVERNMENT %} - {% namespaced_url 'domain-request' step as domain_request_url %} - {% with title=form_titles|get_item:step value=domain_request.tribe_name|default:"Incomplete"|safe %} - {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=domain_request_url %} - {% endwith %} - {% if domain_request.federally_recognized_tribe %}

Federally-recognized tribe

{% endif %} - {% if domain_request.state_recognized_tribe %}

State-recognized tribe

{% endif %} - {% endif %} - - - {% if step == Step.ORGANIZATION_FEDERAL %} - {% namespaced_url 'domain-request' step as domain_request_url %} - {% with title=form_titles|get_item:step value=domain_request.get_federal_type_display|default:"Incomplete"|safe %} - {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=domain_request_url %} - {% endwith %} - {% endif %} - - {% if step == Step.ORGANIZATION_ELECTION %} - {% namespaced_url 'domain-request' step as domain_request_url %} - {% with title=form_titles|get_item:step value=domain_request.is_election_board|yesno:"Yes,No,Incomplete" %} - {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=domain_request_url %} - {% endwith %} - {% endif %} - - {% if step == Step.ORGANIZATION_CONTACT %} - {% namespaced_url 'domain-request' step as domain_request_url %} - {% if domain_request.organization_name %} - {% with title=form_titles|get_item:step value=domain_request %} - {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=domain_request_url address='true' %} - {% endwith %} - {% else %} - {% with title=form_titles|get_item:step value="Incomplete"|safe %} - {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=domain_request_url %} - {% endwith %} - {% endif %} - {% endif %} - - {% if step == Step.ABOUT_YOUR_ORGANIZATION %} - {% namespaced_url 'domain-request' step as domain_request_url %} - {% with title=form_titles|get_item:step value=domain_request.about_your_organization|default:"Incomplete"|safe %} - {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=domain_request_url %} - {% endwith %} - {% endif %} - - {% if step == Step.SENIOR_OFFICIAL %} - {% namespaced_url 'domain-request' step as domain_request_url %} - {% if domain_request.senior_official is not None %} - {% with title=form_titles|get_item:step value=domain_request.senior_official %} - {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=domain_request_url contact='true' %} - {% endwith %} - {% else %} - {% with title=form_titles|get_item:step value="Incomplete"|safe %} - {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=domain_request_url %} - {% endwith %} - {% endif %} - {% endif %} - - {% if step == Step.CURRENT_SITES %} - {% namespaced_url 'domain-request' step as domain_request_url %} - {% if domain_request.current_websites.all %} - {% with title=form_titles|get_item:step value=domain_request.current_websites.all %} - {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=domain_request_url list='true' %} - {% endwith %} - {% else %} - {% with title=form_titles|get_item:step value='None' %} - {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=domain_request_url %} - {% endwith %} - {% endif %} - {% endif %} - - {% if step == Step.DOTGOV_DOMAIN %} - {% namespaced_url 'domain-request' step as domain_request_url %} - {% with title=form_titles|get_item:step value=domain_request.requested_domain.name|default:"Incomplete"|safe%} - {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=domain_request_url %} - {% endwith %} - - {% if domain_request.alternative_domains.all %} -

Alternative domains

- - {% endif %} - {% endif %} - - {% if step == Step.PURPOSE %} - {% namespaced_url 'domain-request' step as domain_request_url %} - {% with title=form_titles|get_item:step value=domain_request.purpose|default:"Incomplete"|safe %} - {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=domain_request_url %} - {% endwith %} - {% endif %} - - {% if step == Step.YOUR_CONTACT %} - {% namespaced_url 'domain-request' step as domain_request_url %} - {% if domain_request.creator is not None %} - {% with title=form_titles|get_item:step value=domain_request.creator %} - {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=domain_request_url contact='true' %} - {% endwith %} - {% else %} - {% with title=form_titles|get_item:step value="Incomplete"|safe %} - {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=domain_request_url %} - {% endwith %} - {% endif %} - {% endif %} - - {% if step == Step.OTHER_CONTACTS %} - {% namespaced_url 'domain-request' step as domain_request_url %} - {% if domain_request.other_contacts.all %} - {% with title=form_titles|get_item:step value=domain_request.other_contacts.all %} - {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=domain_request_url contact='true' list='true' %} - {% endwith %} - {% else %} - {% with title=form_titles|get_item:step value=domain_request.no_other_contacts_rationale|default:"Incomplete"|safe %} - {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=domain_request_url %} - {% endwith %} - {% endif %} - {% endif %} - - - {% if step == Step.ADDITIONAL_DETAILS %} - {% namespaced_url 'domain-request' step as domain_request_url %} - {% with title=form_titles|get_item:step %} - {% if domain_request.has_additional_details %} - {% include "includes/summary_item.html" with title="Additional Details" value=" " heading_level=heading_level editable=True edit_link=domain_request_url %} -

CISA Regional Representative

- - -

Anything else

- - {% else %} - {% include "includes/summary_item.html" with title="Additional Details" value="Incomplete"|safe heading_level=heading_level editable=True edit_link=domain_request_url %} - {% endif %} - {% endwith %} - {% endif %} - - - {% if step == Step.REQUIREMENTS %} - {% namespaced_url 'domain-request' step as domain_request_url %} - {% with title=form_titles|get_item:step value=domain_request.is_policy_acknowledged|yesno:"I agree.,I do not agree.,I do not agree." %} - {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=domain_request_url %} - {% endwith %} - {% endif %} - - - -
- {% endfor %} + {% if not portfolio %} + {% include "includes/domain_request_review_steps.html" with is_editable=True %} + {% else %} + {% include "includes/portfolio_domain_request_review_steps.html" with is_editable=True %} + {% endif %} {% endblock %} diff --git a/src/registrar/templates/includes/domain_request_review_steps.html b/src/registrar/templates/includes/domain_request_review_steps.html new file mode 100644 index 000000000..d292f61a9 --- /dev/null +++ b/src/registrar/templates/includes/domain_request_review_steps.html @@ -0,0 +1,168 @@ +{% load custom_filters %} +{% load static url_helpers %} + +{% for step in steps %} +
+ {% if is_editable %} + {% namespaced_url 'domain-request' step as domain_request_url %} + {% endif %} + + {% if step == Step.ORGANIZATION_TYPE %} + {% if domain_request.generic_org_type is not None %} + {% with title=form_titles|get_item:step value=domain_request.get_generic_org_type_display|default:"Incomplete"|safe %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=is_editable edit_link=domain_request_url %} + {% endwith %} + {% else %} + {% with title=form_titles|get_item:step value="Incomplete"|safe %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=is_editable edit_link=domain_request_url %} + {% endwith %} + {% endif %} + {% endif %} + + {% if step == Step.TRIBAL_GOVERNMENT %} + {% with title=form_titles|get_item:step value=domain_request.tribe_name|default:"Incomplete"|safe %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=is_editable edit_link=domain_request_url %} + {% endwith %} + {% if domain_request.federally_recognized_tribe %}

Federally-recognized tribe

{% endif %} + {% if domain_request.state_recognized_tribe %}

State-recognized tribe

{% endif %} + {% endif %} + + + {% if step == Step.ORGANIZATION_FEDERAL %} + {% with title=form_titles|get_item:step value=domain_request.get_federal_type_display|default:"Incomplete"|safe %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=is_editable edit_link=domain_request_url %} + {% endwith %} + {% endif %} + + {% if step == Step.ORGANIZATION_ELECTION %} + {% with title=form_titles|get_item:step value=domain_request.is_election_board|yesno:"Yes,No,Incomplete" %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=is_editable edit_link=domain_request_url %} + {% endwith %} + {% endif %} + + {% if step == Step.ORGANIZATION_CONTACT %} + {% if domain_request.organization_name %} + {% with title=form_titles|get_item:step value=domain_request %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=is_editable edit_link=domain_request_url address='true' %} + {% endwith %} + {% else %} + {% with title=form_titles|get_item:step value="Incomplete"|safe %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=is_editable edit_link=domain_request_url %} + {% endwith %} + {% endif %} + {% endif %} + + {% if step == Step.ABOUT_YOUR_ORGANIZATION %} + {% with title=form_titles|get_item:step value=domain_request.about_your_organization|default:"Incomplete"|safe %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=is_editable edit_link=domain_request_url %} + {% endwith %} + {% endif %} + + {% if step == Step.SENIOR_OFFICIAL %} + {% if domain_request.senior_official is not None %} + {% with title=form_titles|get_item:step value=domain_request.senior_official %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=is_editable edit_link=domain_request_url contact='true' %} + {% endwith %} + {% else %} + {% with title=form_titles|get_item:step value="Incomplete"|safe %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=is_editable edit_link=domain_request_url %} + {% endwith %} + {% endif %} + {% endif %} + + {% if step == Step.CURRENT_SITES %} + {% if domain_request.current_websites.all %} + {% with title=form_titles|get_item:step value=domain_request.current_websites.all %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=is_editable edit_link=domain_request_url list='true' %} + {% endwith %} + {% else %} + {% with title=form_titles|get_item:step value='None' %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=is_editable edit_link=domain_request_url %} + {% endwith %} + {% endif %} + {% endif %} + + {% if step == Step.DOTGOV_DOMAIN %} + {% with title=form_titles|get_item:step value=domain_request.requested_domain.name|default:"Incomplete"|safe%} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=is_editable edit_link=domain_request_url %} + {% endwith %} + + {% if domain_request.alternative_domains.all %} +

Alternative domains

+ + {% endif %} + {% endif %} + + {% if step == Step.PURPOSE %} + {% with title=form_titles|get_item:step value=domain_request.purpose|default:"Incomplete"|safe %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=is_editable edit_link=domain_request_url %} + {% endwith %} + {% endif %} + + {% if step == Step.YOUR_CONTACT %} + {% if domain_request.creator is not None %} + {% with title=form_titles|get_item:step value=domain_request.creator %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=is_editable edit_link=domain_request_url contact='true' %} + {% endwith %} + {% else %} + {% with title=form_titles|get_item:step value="Incomplete"|safe %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=is_editable edit_link=domain_request_url %} + {% endwith %} + {% endif %} + {% endif %} + + {% if step == Step.OTHER_CONTACTS %} + {% if domain_request.other_contacts.all %} + {% with title=form_titles|get_item:step value=domain_request.other_contacts.all %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=is_editable edit_link=domain_request_url contact='true' list='true' %} + {% endwith %} + {% else %} + {% with title=form_titles|get_item:step value=domain_request.no_other_contacts_rationale|default:"Incomplete"|safe %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=is_editable edit_link=domain_request_url %} + {% endwith %} + {% endif %} + {% endif %} + + + {% if step == Step.ADDITIONAL_DETAILS %} + {% with title=form_titles|get_item:step %} + {% if domain_request.has_additional_details %} + {% include "includes/summary_item.html" with title="Additional Details" value=" " heading_level=heading_level editable=is_editable edit_link=domain_request_url %} +

CISA Regional Representative

+ + +

Anything else

+ + {% else %} + {% include "includes/summary_item.html" with title="Additional Details" value="Incomplete"|safe heading_level=heading_level editable=is_editable edit_link=domain_request_url %} + {% endif %} + {% endwith %} + {% endif %} + + + {% if step == Step.REQUIREMENTS %} + {% with title=form_titles|get_item:step value=domain_request.is_policy_acknowledged|yesno:"I agree.,I do not agree.,I do not agree." %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=is_editable edit_link=domain_request_url %} + {% endwith %} + {% endif %} +
+{% endfor %} \ No newline at end of file diff --git a/src/registrar/templates/includes/domain_request_status_view.html b/src/registrar/templates/includes/domain_request_status_view.html index 22365e06e..b94623320 100644 --- a/src/registrar/templates/includes/domain_request_status_view.html +++ b/src/registrar/templates/includes/domain_request_status_view.html @@ -15,75 +15,5 @@ {% block request_summary %} - {% with heading_level='h3' org_type=DomainRequest.get_generic_org_type_display %} - - {% include "includes/summary_item.html" with title='Type of organization' value=org_type heading_level=heading_level custom_text_for_value_none="Incomplete" %} - - {% if DomainRequest.show_tribal_government %} - {% include "includes/summary_item.html" with title='Tribal government' value=DomainRequest.tribe_name heading_level=heading_level custom_text_for_value_none="Incomplete" %} - - {% if DomainRequest.federally_recognized_tribe %} -

Federally-recognized tribe

- {% endif %} - - {% if DomainRequest.state_recognized_tribe %} -

State-recognized tribe

- {% endif %} - {% endif %} - - {% if DomainRequest.show_organization_federal %} - {% include "includes/summary_item.html" with title='Federal government branch' value=DomainRequest.get_federal_type_display heading_level=heading_level custom_text_for_value_none="Incomplete" %} - {% endif %} - - {% if DomainRequest.show_organization_election %} - {% with value=DomainRequest.is_election_board|yesno:"Yes,No,Incomplete" %} - {% include "includes/summary_item.html" with title='Election office' value=value heading_level=heading_level %} - {% endwith %} - {% endif %} - - {% if not portfolio %} - {% include "includes/summary_item.html" with title='Organization' value=DomainRequest address='true' heading_level=heading_level custom_text_for_value_none="Incomplete" %} - {% endif %} - - {% if DomainRequest.show_about_your_organization %} - {% include "includes/summary_item.html" with title='About your organization' value=DomainRequest.about_your_organization heading_level=heading_level custom_text_for_value_none="Incomplete" %} - {% endif %} - - {% include "includes/summary_item.html" with title='Senior official' value=DomainRequest.senior_official contact='true' heading_level=heading_level custom_text_for_value_none="Incomplete" %} - - {% include "includes/summary_item.html" with title='Current websites' value=DomainRequest.current_websites.all list='true' heading_level=heading_level %} - - {% include "includes/summary_item.html" with title='.gov domain' value=DomainRequest.requested_domain heading_level=heading_level custom_text_for_value_none="Incomplete" %} - - {% include "includes/summary_item.html" with title='Alternative domains' value=DomainRequest.alternative_domains.all list='true' heading_level=heading_level %} - - {% include "includes/summary_item.html" with title='Purpose of your domain' value=DomainRequest.purpose heading_level=heading_level custom_text_for_value_none="Incomplete" %} - - {% if DomainRequest.other_contacts.all %} - {% include "includes/summary_item.html" with title='Other employees from your organization' value=DomainRequest.other_contacts.all contact='true' list='true' heading_level=heading_level custom_text_for_value_none="Incomplete" %} - {% else %} - {% include "includes/summary_item.html" with title='Other employees from your organization' value=DomainRequest.no_other_contacts_rationale heading_level=heading_level custom_text_for_value_none="Incomplete" %} - {% endif %} - - {# We always show this field even if None #} - {% if DomainRequest %} -

CISA Regional Representative

- - -

Anything else

- - {% endif %} - {% endwith %} + {% include "includes/portfolio_domain_request_review_steps.html" with domain_request=DomainRequest is_editable=False %} {% endblock request_summary %} diff --git a/src/registrar/templates/includes/portfolio_domain_request_review_steps.html b/src/registrar/templates/includes/portfolio_domain_request_review_steps.html new file mode 100644 index 000000000..c61c09657 --- /dev/null +++ b/src/registrar/templates/includes/portfolio_domain_request_review_steps.html @@ -0,0 +1,86 @@ +{% load custom_filters %} +{% load static url_helpers %} + +{% for step in steps %} +
+ {% if is_editable %} + {% namespaced_url 'domain-request' step as domain_request_url %} + {% endif %} + + {% comment %} TODO: what is this? {% endcomment %} + {% if step == Step.REQUESTING_ENTITY %} + {% with title=form_titles|get_item:step value=domain_request.portfolio|default:"Incomplete"|safe%} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=is_editable edit_link=domain_request_url %} + {% endwith %} + {% endif %} + + {% if step == Step.CURRENT_SITES %} + {% if domain_request.current_websites.all %} + {% with title=form_titles|get_item:step value=domain_request.current_websites.all %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=is_editable edit_link=domain_request_url list='true' %} + {% endwith %} + {% else %} + {% with title=form_titles|get_item:step value='None' %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=is_editable edit_link=domain_request_url %} + {% endwith %} + {% endif %} + {% endif %} + + {% if step == Step.DOTGOV_DOMAIN %} + {% with title=form_titles|get_item:step value=domain_request.requested_domain.name|default:"Incomplete"|safe%} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=is_editable edit_link=domain_request_url %} + {% endwith %} + + {% if domain_request.alternative_domains.all %} +

Alternative domains

+ + {% endif %} + {% endif %} + + {% if step == Step.PURPOSE %} + {% with title=form_titles|get_item:step value=domain_request.purpose|default:"Incomplete"|safe %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=is_editable edit_link=domain_request_url %} + {% endwith %} + {% endif %} + + {% if step == Step.ADDITIONAL_DETAILS %} + {% with title=form_titles|get_item:step %} + {% if domain_request.has_additional_details %} + {% include "includes/summary_item.html" with title="Additional Details" value=" " heading_level=heading_level editable=is_editable edit_link=domain_request_url %} +

CISA Regional Representative

+ + +

Anything else

+ + {% else %} + {% include "includes/summary_item.html" with title="Additional Details" value="Incomplete"|safe heading_level=heading_level editable=is_editable edit_link=domain_request_url %} + {% endif %} + {% endwith %} + {% endif %} + + {% if step == Step.REQUIREMENTS %} + {% with title=form_titles|get_item:step value=domain_request.is_policy_acknowledged|yesno:"I agree.,I do not agree.,I do not agree." %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=is_editable edit_link=domain_request_url %} + {% endwith %} + {% endif %} +
+{% endfor %} \ No newline at end of file diff --git a/src/registrar/utility/enums.py b/src/registrar/utility/enums.py index 706eee1fc..3cc0b2c47 100644 --- a/src/registrar/utility/enums.py +++ b/src/registrar/utility/enums.py @@ -1,7 +1,7 @@ """Used for holding various enums""" from enum import Enum - +from registrar.utility import StrEnum class ValidationReturnType(Enum): """Determines the return value of the validate_and_handle_errors class""" @@ -38,3 +38,32 @@ class DefaultEmail(Enum): PUBLIC_CONTACT_DEFAULT = "dotgov@cisa.dhs.gov" LEGACY_DEFAULT = "registrar@dotgov.gov" + + +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.) + """ + # Portfolio + # TODO - this does not exist yet. + # Fill this in for the portfolio domain request experience. + REQUESTING_ENTITY = "portfolio" + + # Non-Portfolio + 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" diff --git a/src/registrar/views/domain_request.py b/src/registrar/views/domain_request.py index 4fe59c70c..05a7e6827 100644 --- a/src/registrar/views/domain_request.py +++ b/src/registrar/views/domain_request.py @@ -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