diff --git a/src/registrar/config/urls.py b/src/registrar/config/urls.py index 9b9ed569e..f45770cf6 100644 --- a/src/registrar/config/urls.py +++ b/src/registrar/config/urls.py @@ -169,6 +169,11 @@ urlpatterns = [ views.DomainRequestStatus.as_view(), name="domain-request-status", ), + path( + "domain-request/viewonly/", + views.PortfolioDomainRequestStatusViewOnly.as_view(), + name="domain-request-status-viewonly", + ), path( "domain-request//withdraw", views.DomainRequestWithdrawConfirmation.as_view(), diff --git a/src/registrar/forms/utility/wizard_form_helper.py b/src/registrar/forms/utility/wizard_form_helper.py index 2ae50f908..ba3c37e1e 100644 --- a/src/registrar/forms/utility/wizard_form_helper.py +++ b/src/registrar/forms/utility/wizard_form_helper.py @@ -4,7 +4,6 @@ from itertools import zip_longest from typing import Callable from django.db.models.fields.related import ForeignObjectRel from django import forms - from registrar.models import DomainRequest, Contact @@ -278,3 +277,15 @@ 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 request_wizard.StepEnum: + 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/models/domain_request.py b/src/registrar/models/domain_request.py index 161d85ae5..bb8693ac1 100644 --- a/src/registrar/models/domain_request.py +++ b/src/registrar/models/domain_request.py @@ -583,6 +583,10 @@ class DomainRequest(TimeStampedModel): blank=True, ) + def is_awaiting_review(self) -> bool: + """Checks if the current status is in submitted or in_review""" + return self.status in [self.DomainRequestStatus.SUBMITTED, self.DomainRequestStatus.IN_REVIEW] + def get_first_status_set_date(self, status): """Returns the date when the domain request was first set to the given status.""" log_entry = ( @@ -1001,6 +1005,17 @@ class DomainRequest(TimeStampedModel): send_email=send_email, ) + def is_withdrawable(self): + """Helper function that determines if the request can be withdrawn in its current status""" + # This list is equivalent to the source field on withdraw. We need a better way to + # consolidate these two lists - i.e. some sort of method that keeps these two lists in sync. + # django fsm is very picky with what we can define in that field. + return self.status in [ + self.DomainRequestStatus.SUBMITTED, + self.DomainRequestStatus.IN_REVIEW, + self.DomainRequestStatus.ACTION_NEEDED, + ] + @transition( field="status", source=[DomainRequestStatus.SUBMITTED, DomainRequestStatus.IN_REVIEW, DomainRequestStatus.ACTION_NEEDED], diff --git a/src/registrar/templates/domain_request_review.html b/src/registrar/templates/domain_request_review.html index ced20b6b7..03624d2ec 100644 --- a/src/registrar/templates/domain_request_review.html +++ b/src/registrar/templates/domain_request_review.html @@ -19,183 +19,5 @@ {% 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

-
    - {% for site in domain_request.alternative_domains.all %} -
  • {{ site.website }}
  • - {% endfor %} -
- {% 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

-
    - {% if domain_request.cisa_representative_first_name %} -
  • {{domain_request.cisa_representative_first_name}} {{domain_request.cisa_representative_last_name}}
  • - {% if domain_request.cisa_representative_email %} -
  • {{domain_request.cisa_representative_email}}
  • - {% endif %} - {% else %} - No - {% endif %} -
- -

Anything else

-
    - {% if domain_request.anything_else %} - {{domain_request.anything_else}} - {% else %} - No - {% endif %} -
- {% 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 %} + {% include "includes/request_review_steps.html" with is_editable=True %} {% endblock %} diff --git a/src/registrar/templates/domain_request_status.html b/src/registrar/templates/domain_request_status.html index 460f6ae29..d332ce54e 100644 --- a/src/registrar/templates/domain_request_status.html +++ b/src/registrar/templates/domain_request_status.html @@ -1,206 +1,10 @@ {% extends 'base.html' %} - {% load custom_filters %} - -{% block title %}Domain request status | {{ DomainRequest.requested_domain.name }} | {% endblock %} {% load static url_helpers %} +{% block title %}Domain request status | {{ DomainRequest.requested_domain.name }} | {% endblock %} + + {% block content %} -
-
- {% if portfolio %} - {% url 'domain-requests' as url %} - {% else %} - {% url 'home' as url %} - {% endif %} - - -

Domain request for {{ DomainRequest.requested_domain.name }}

-
-
-

- - Status: - - {{ DomainRequest.get_status_display|default:"ERROR Please contact technical support/dev" }} -

-
-
-
- - {% with statuses=DomainRequest.DomainRequestStatus last_submitted=DomainRequest.last_submitted_date|date:"F j, Y" first_submitted=DomainRequest.first_submitted_date|date:"F j, Y" last_status_update=DomainRequest.last_status_update|date:"F j, Y" %} - {% comment %} - These are intentionally seperated this way. - There is some code repetition, but it gives us more flexibility rather than a dense reduction. - Leave it this way until we've solidified our requirements. - {% endcomment %} - {% if DomainRequest.status == statuses.STARTED %} - {% with first_started_date=DomainRequest.get_first_status_started_date|date:"F j, Y" %} -

- {% comment %} - A newly created domain request will not have a value for last_status update. - This is because the status never really updated. - However, if this somehow goes back to started we can default to displaying that new date. - {% endcomment %} - Started on: {{last_status_update|default:first_started_date}} -

- {% endwith %} - {% elif DomainRequest.status == statuses.SUBMITTED %} -

- Submitted on: {{last_submitted|default:first_submitted }} -

-

- Last updated on: {{DomainRequest.updated_at|date:"F j, Y"}} -

- {% elif DomainRequest.status == statuses.ACTION_NEEDED %} -

- Submitted on: {{last_submitted|default:first_submitted }} -

-

- Last updated on: {{DomainRequest.updated_at|date:"F j, Y"}} -

- {% elif DomainRequest.status == statuses.REJECTED %} -

- Submitted on: {{last_submitted|default:first_submitted }} -

-

- Rejected on: {{last_status_update}} -

- {% elif DomainRequest.status == statuses.WITHDRAWN %} -

- Submitted on: {{last_submitted|default:first_submitted }} -

-

- Withdrawn on: {{last_status_update}} -

- {% else %} - {% comment %} Shown for in_review, approved, ineligible {% endcomment %} -

- Last updated on: {{DomainRequest.updated_at|date:"F j, Y"}} -

- {% endif %} - - {% if DomainRequest.status != 'rejected' %} -

{% include "includes/domain_request.html" %}

-

- Withdraw request -

- {% endif %} - {% endwith %} -
- -
-

Summary of your domain request

- {% with heading_level='h3' %} - {% with 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 %} - {% endwith %} - - {% if DomainRequest.tribe_name %} - {% include "includes/summary_item.html" with title='Tribal government' value=DomainRequest.tribe_name heading_level=heading_level %} - - {% if DomainRequest.federally_recognized_tribe %} -

Federally-recognized tribe

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

State-recognized tribe

- {% endif %} - - {% endif %} - - {% if DomainRequest.get_federal_type_display %} - {% include "includes/summary_item.html" with title='Federal government branch' value=DomainRequest.get_federal_type_display heading_level=heading_level %} - {% endif %} - - {% if DomainRequest.is_election_board %} - {% 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 DomainRequest.organization_name %} - {% include "includes/summary_item.html" with title='Organization' value=DomainRequest address='true' heading_level=heading_level %} - {% endif %} - - {% if DomainRequest.about_your_organization %} - {% include "includes/summary_item.html" with title='About your organization' value=DomainRequest.about_your_organization heading_level=heading_level %} - {% endif %} - - {% if DomainRequest.senior_official %} - {% include "includes/summary_item.html" with title='Senior official' value=DomainRequest.senior_official contact='true' heading_level=heading_level %} - {% endif %} - - {% if DomainRequest.current_websites.all %} - {% include "includes/summary_item.html" with title='Current websites' value=DomainRequest.current_websites.all list='true' heading_level=heading_level %} - {% endif %} - - {% if DomainRequest.requested_domain %} - {% include "includes/summary_item.html" with title='.gov domain' value=DomainRequest.requested_domain heading_level=heading_level %} - {% endif %} - - {% if DomainRequest.alternative_domains.all %} - {% include "includes/summary_item.html" with title='Alternative domains' value=DomainRequest.alternative_domains.all list='true' heading_level=heading_level %} - {% endif %} - - {% if DomainRequest.purpose %} - {% include "includes/summary_item.html" with title='Purpose of your domain' value=DomainRequest.purpose heading_level=heading_level %} - {% endif %} - - {% if DomainRequest.creator %} - {% include "includes/summary_item.html" with title='Your contact information' value=DomainRequest.creator contact='true' heading_level=heading_level %} - {% endif %} - {% 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 %} - {% else %} - {% include "includes/summary_item.html" with title='Other employees from your organization' value=DomainRequest.no_other_contacts_rationale heading_level=heading_level %} - {% endif %} - - {# We always show this field even if None #} - {% if DomainRequest %} -

CISA Regional Representative

-
    - {% if DomainRequest.cisa_representative_first_name %} - {{ DomainRequest.get_formatted_cisa_rep_name }} - {% else %} - No - {% endif %} -
- -

Anything else

-
    - {% if DomainRequest.anything_else %} - {{DomainRequest.anything_else}} - {% else %} - No - {% endif %} -
- {% endif %} - {% endwith %} -
- -
+ {% include "includes/request_status_manage.html" %} {% endblock %} diff --git a/src/registrar/templates/includes/domain_request.html b/src/registrar/templates/includes/domain_request_awaiting_review.html similarity index 57% rename from src/registrar/templates/includes/domain_request.html rename to src/registrar/templates/includes/domain_request_awaiting_review.html index 0e377f35c..cc9b31ccb 100644 --- a/src/registrar/templates/includes/domain_request.html +++ b/src/registrar/templates/includes/domain_request_awaiting_review.html @@ -5,8 +5,10 @@

We received your .gov domain request. Our next step is to review your request. This usually takes 30 business days. We’ll email you if we have questions and when we complete our review. Contact us with any questions.

-

- Need to make changes? -

+{% if show_withdraw_text %} +

+ Need to make changes? +

-

If you need to change your request you have to first withdraw it. Once you withdraw the request you can edit it and submit it again. Changing your request might add to the wait time.

+

If you need to change your request you have to first withdraw it. Once you withdraw the request you can edit it and submit it again. Changing your request might add to the wait time.

+{% endif %} diff --git a/src/registrar/templates/includes/domain_request_status_manage.html b/src/registrar/templates/includes/domain_request_status_manage.html new file mode 100644 index 000000000..2a254df4b --- /dev/null +++ b/src/registrar/templates/includes/domain_request_status_manage.html @@ -0,0 +1,236 @@ +{% load custom_filters %} +{% load static url_helpers %} +
+
+ {% block breadcrumb %} + {% if portfolio %} + {% url 'domain-requests' as url %} + {% else %} + {% url 'home' as url %} + {% endif %} + + {% endblock breadcrumb %} + + {% block header %} + {% if not DomainRequest.requested_domain and DomainRequest.status == DomainRequest.DomainRequestStatus.STARTED %} +

New domain request

+ {% else %} +

Domain request for {{ DomainRequest.requested_domain.name }}

+ {% endif %} + {% endblock header %} + + {% block status_summary %} +
+
+

+ + Status: + + {{ DomainRequest.get_status_display|default:"ERROR Please contact technical support/dev" }} +

+
+
+
+ {% endblock status_summary %} + + {% block status_metadata %} + + {% if portfolio %} + {% if DomainRequest.creator %} +

+ Created by: {{DomainRequest.creator.email|default:DomainRequest.creator.get_formatted_name }} +

+ {% else %} +

+ No creator found: this is an error, please email help@get.gov. +

+ {% endif %} + {% endif %} + + {% with statuses=DomainRequest.DomainRequestStatus last_submitted=DomainRequest.last_submitted_date|date:"F j, Y" first_submitted=DomainRequest.first_submitted_date|date:"F j, Y" last_status_update=DomainRequest.last_status_update|date:"F j, Y" %} + {% comment %} + These are intentionally seperated this way. + There is some code repetition, but it gives us more flexibility rather than a dense reduction. + Leave it this way until we've solidified our requirements. + {% endcomment %} + {% if DomainRequest.status == statuses.STARTED %} + {% with first_started_date=DomainRequest.get_first_status_started_date|date:"F j, Y" %} +

+ {% comment %} + A newly created domain request will not have a value for last_status update. + This is because the status never really updated. + However, if this somehow goes back to started we can default to displaying that new date. + {% endcomment %} + Started on: {{last_status_update|default:first_started_date}} +

+ {% endwith %} + {% elif DomainRequest.status == statuses.SUBMITTED %} +

+ Submitted on: {{last_submitted|default:first_submitted }} +

+

+ Last updated on: {{DomainRequest.updated_at|date:"F j, Y"}} +

+ {% elif DomainRequest.status == statuses.ACTION_NEEDED %} +

+ Submitted on: {{last_submitted|default:first_submitted }} +

+

+ Last updated on: {{DomainRequest.updated_at|date:"F j, Y"}} +

+ {% elif DomainRequest.status == statuses.REJECTED %} +

+ Submitted on: {{last_submitted|default:first_submitted }} +

+

+ Rejected on: {{last_status_update}} +

+ {% elif DomainRequest.status == statuses.WITHDRAWN %} +

+ Submitted on: {{last_submitted|default:first_submitted }} +

+

+ Withdrawn on: {{last_status_update}} +

+ {% else %} + {% comment %} Shown for in_review, approved, ineligible {% endcomment %} +

+ Last updated on: {{DomainRequest.updated_at|date:"F j, Y"}} +

+ {% endif %} + {% endwith %} + {% endblock status_metadata %} + + {% block status_blurb %} + {% if DomainRequest.is_awaiting_review %} +

{% include "includes/domain_request_awaiting_review.html" with show_withdraw_text=DomainRequest.is_withdrawable %}

+ {% endif %} + {% endblock status_blurb %} + + {% block modify_request %} + {% if DomainRequest.is_withdrawable %} +

+ Withdraw request +

+ {% endif %} + {% endblock modify_request %} +
+ +
+ {% block request_summary_header %} +

Summary of your domain request

+ {% endblock request_summary_header%} + + {% block request_summary %} + {% with heading_level='h3' %} + {% with 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 %} + {% endwith %} + + {% if DomainRequest.tribe_name %} + {% include "includes/summary_item.html" with title='Tribal government' value=DomainRequest.tribe_name heading_level=heading_level %} + + {% if DomainRequest.federally_recognized_tribe %} +

Federally-recognized tribe

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

State-recognized tribe

+ {% endif %} + + {% endif %} + + {% if DomainRequest.get_federal_type_display %} + {% include "includes/summary_item.html" with title='Federal government branch' value=DomainRequest.get_federal_type_display heading_level=heading_level %} + {% endif %} + + {% if DomainRequest.is_election_board %} + {% 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 DomainRequest.organization_name %} + {% include "includes/summary_item.html" with title='Organization' value=DomainRequest address='true' heading_level=heading_level %} + {% endif %} + + {% if DomainRequest.about_your_organization %} + {% include "includes/summary_item.html" with title='About your organization' value=DomainRequest.about_your_organization heading_level=heading_level %} + {% endif %} + + {% if DomainRequest.senior_official %} + {% include "includes/summary_item.html" with title='Senior official' value=DomainRequest.senior_official contact='true' heading_level=heading_level %} + {% endif %} + + {% if DomainRequest.current_websites.all %} + {% include "includes/summary_item.html" with title='Current websites' value=DomainRequest.current_websites.all list='true' heading_level=heading_level %} + {% endif %} + + {% if DomainRequest.requested_domain %} + {% include "includes/summary_item.html" with title='.gov domain' value=DomainRequest.requested_domain heading_level=heading_level %} + {% endif %} + + {% if DomainRequest.alternative_domains.all %} + {% include "includes/summary_item.html" with title='Alternative domains' value=DomainRequest.alternative_domains.all list='true' heading_level=heading_level %} + {% endif %} + + {% if DomainRequest.purpose %} + {% include "includes/summary_item.html" with title='Purpose of your domain' value=DomainRequest.purpose heading_level=heading_level %} + {% endif %} + + {% if DomainRequest.creator %} + {% include "includes/summary_item.html" with title='Your contact information' value=DomainRequest.creator contact='true' heading_level=heading_level %} + {% endif %} + + {% 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 %} + {% else %} + {% include "includes/summary_item.html" with title='Other employees from your organization' value=DomainRequest.no_other_contacts_rationale heading_level=heading_level %} + {% endif %} + + {# We always show this field even if None #} + {% if DomainRequest %} +

CISA Regional Representative

+
    + {% if DomainRequest.cisa_representative_first_name %} + {{ DomainRequest.get_formatted_cisa_rep_name }} + {% else %} + No + {% endif %} +
+

Anything else

+
    + {% if DomainRequest.anything_else %} + {{DomainRequest.anything_else}} + {% else %} + No + {% endif %} +
+ {% endif %} + {% endwith %} + {% endblock request_summary%} +
+
\ No newline at end of file diff --git a/src/registrar/templates/includes/organization_address.html b/src/registrar/templates/includes/organization_address.html index c0baf3c9f..d6126d681 100644 --- a/src/registrar/templates/includes/organization_address.html +++ b/src/registrar/templates/includes/organization_address.html @@ -25,4 +25,4 @@ {% if organization.urbanization %}
{{ organization.urbanization }} {% endif %} - \ No newline at end of file + diff --git a/src/registrar/templates/includes/portfolio_request_review_steps.html b/src/registrar/templates/includes/portfolio_request_review_steps.html new file mode 100644 index 000000000..8f7dba9ac --- /dev/null +++ b/src/registrar/templates/includes/portfolio_request_review_steps.html @@ -0,0 +1,92 @@ +{% 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.REQUESTING_ENTITY %} + + {% 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.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

+
    + {% for site in domain_request.alternative_domains.all %} +
  • {{ site.website }}
  • + {% endfor %} +
+ {% 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

+
    + {% if domain_request.cisa_representative_first_name %} +
  • {{domain_request.cisa_representative_first_name}} {{domain_request.cisa_representative_last_name}}
  • + {% if domain_request.cisa_representative_email %} +
  • {{domain_request.cisa_representative_email}}
  • + {% endif %} + {% else %} + No + {% endif %} +
+ +

Anything else

+
    + {% if domain_request.anything_else %} + {{domain_request.anything_else}} + {% else %} + No + {% endif %} +
+ {% 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/portfolio_request_status_view.html b/src/registrar/templates/includes/portfolio_request_status_view.html new file mode 100644 index 000000000..528c97709 --- /dev/null +++ b/src/registrar/templates/includes/portfolio_request_status_view.html @@ -0,0 +1,18 @@ +{% extends 'includes/request_status_manage.html' %} +{% load custom_filters %} +{% load static url_helpers %} + +{% comment %} Do not show the withdrawal text in viewonly mode {% endcomment %} +{% block status_blurb %} + {% if DomainRequest.is_awaiting_review %} +

{% include "includes/domain_request_awaiting_review.html" with show_withdraw_text=False %}

+ {% endif %} +{% endblock status_blurb %} + +{% comment %} Do not show action buttons in viewonly mode {% endcomment %} +{% block modify_request %} +{% endblock modify_request %} + +{% block request_summary %} + {% include "includes/portfolio_request_review_steps.html" with domain_request=DomainRequest is_editable=False %} +{% endblock request_summary %} diff --git a/src/registrar/templates/includes/request_review_steps.html b/src/registrar/templates/includes/request_review_steps.html new file mode 100644 index 000000000..db1743b34 --- /dev/null +++ b/src/registrar/templates/includes/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

+
    + {% for site in domain_request.alternative_domains.all %} +
  • {{ site.website }}
  • + {% endfor %} +
+ {% 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

+
    + {% if domain_request.cisa_representative_first_name %} +
  • {{domain_request.cisa_representative_first_name}} {{domain_request.cisa_representative_last_name}}
  • + {% if domain_request.cisa_representative_email %} +
  • {{domain_request.cisa_representative_email}}
  • + {% endif %} + {% else %} + No + {% endif %} +
+ +

Anything else

+
    + {% if domain_request.anything_else %} + {{domain_request.anything_else}} + {% else %} + No + {% endif %} +
+ {% 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 %} diff --git a/src/registrar/templates/includes/request_status_manage.html b/src/registrar/templates/includes/request_status_manage.html new file mode 100644 index 000000000..2a254df4b --- /dev/null +++ b/src/registrar/templates/includes/request_status_manage.html @@ -0,0 +1,236 @@ +{% load custom_filters %} +{% load static url_helpers %} +
+
+ {% block breadcrumb %} + {% if portfolio %} + {% url 'domain-requests' as url %} + {% else %} + {% url 'home' as url %} + {% endif %} + + {% endblock breadcrumb %} + + {% block header %} + {% if not DomainRequest.requested_domain and DomainRequest.status == DomainRequest.DomainRequestStatus.STARTED %} +

New domain request

+ {% else %} +

Domain request for {{ DomainRequest.requested_domain.name }}

+ {% endif %} + {% endblock header %} + + {% block status_summary %} +
+
+

+ + Status: + + {{ DomainRequest.get_status_display|default:"ERROR Please contact technical support/dev" }} +

+
+
+
+ {% endblock status_summary %} + + {% block status_metadata %} + + {% if portfolio %} + {% if DomainRequest.creator %} +

+ Created by: {{DomainRequest.creator.email|default:DomainRequest.creator.get_formatted_name }} +

+ {% else %} +

+ No creator found: this is an error, please email help@get.gov. +

+ {% endif %} + {% endif %} + + {% with statuses=DomainRequest.DomainRequestStatus last_submitted=DomainRequest.last_submitted_date|date:"F j, Y" first_submitted=DomainRequest.first_submitted_date|date:"F j, Y" last_status_update=DomainRequest.last_status_update|date:"F j, Y" %} + {% comment %} + These are intentionally seperated this way. + There is some code repetition, but it gives us more flexibility rather than a dense reduction. + Leave it this way until we've solidified our requirements. + {% endcomment %} + {% if DomainRequest.status == statuses.STARTED %} + {% with first_started_date=DomainRequest.get_first_status_started_date|date:"F j, Y" %} +

+ {% comment %} + A newly created domain request will not have a value for last_status update. + This is because the status never really updated. + However, if this somehow goes back to started we can default to displaying that new date. + {% endcomment %} + Started on: {{last_status_update|default:first_started_date}} +

+ {% endwith %} + {% elif DomainRequest.status == statuses.SUBMITTED %} +

+ Submitted on: {{last_submitted|default:first_submitted }} +

+

+ Last updated on: {{DomainRequest.updated_at|date:"F j, Y"}} +

+ {% elif DomainRequest.status == statuses.ACTION_NEEDED %} +

+ Submitted on: {{last_submitted|default:first_submitted }} +

+

+ Last updated on: {{DomainRequest.updated_at|date:"F j, Y"}} +

+ {% elif DomainRequest.status == statuses.REJECTED %} +

+ Submitted on: {{last_submitted|default:first_submitted }} +

+

+ Rejected on: {{last_status_update}} +

+ {% elif DomainRequest.status == statuses.WITHDRAWN %} +

+ Submitted on: {{last_submitted|default:first_submitted }} +

+

+ Withdrawn on: {{last_status_update}} +

+ {% else %} + {% comment %} Shown for in_review, approved, ineligible {% endcomment %} +

+ Last updated on: {{DomainRequest.updated_at|date:"F j, Y"}} +

+ {% endif %} + {% endwith %} + {% endblock status_metadata %} + + {% block status_blurb %} + {% if DomainRequest.is_awaiting_review %} +

{% include "includes/domain_request_awaiting_review.html" with show_withdraw_text=DomainRequest.is_withdrawable %}

+ {% endif %} + {% endblock status_blurb %} + + {% block modify_request %} + {% if DomainRequest.is_withdrawable %} +

+ Withdraw request +

+ {% endif %} + {% endblock modify_request %} +
+ +
+ {% block request_summary_header %} +

Summary of your domain request

+ {% endblock request_summary_header%} + + {% block request_summary %} + {% with heading_level='h3' %} + {% with 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 %} + {% endwith %} + + {% if DomainRequest.tribe_name %} + {% include "includes/summary_item.html" with title='Tribal government' value=DomainRequest.tribe_name heading_level=heading_level %} + + {% if DomainRequest.federally_recognized_tribe %} +

Federally-recognized tribe

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

State-recognized tribe

+ {% endif %} + + {% endif %} + + {% if DomainRequest.get_federal_type_display %} + {% include "includes/summary_item.html" with title='Federal government branch' value=DomainRequest.get_federal_type_display heading_level=heading_level %} + {% endif %} + + {% if DomainRequest.is_election_board %} + {% 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 DomainRequest.organization_name %} + {% include "includes/summary_item.html" with title='Organization' value=DomainRequest address='true' heading_level=heading_level %} + {% endif %} + + {% if DomainRequest.about_your_organization %} + {% include "includes/summary_item.html" with title='About your organization' value=DomainRequest.about_your_organization heading_level=heading_level %} + {% endif %} + + {% if DomainRequest.senior_official %} + {% include "includes/summary_item.html" with title='Senior official' value=DomainRequest.senior_official contact='true' heading_level=heading_level %} + {% endif %} + + {% if DomainRequest.current_websites.all %} + {% include "includes/summary_item.html" with title='Current websites' value=DomainRequest.current_websites.all list='true' heading_level=heading_level %} + {% endif %} + + {% if DomainRequest.requested_domain %} + {% include "includes/summary_item.html" with title='.gov domain' value=DomainRequest.requested_domain heading_level=heading_level %} + {% endif %} + + {% if DomainRequest.alternative_domains.all %} + {% include "includes/summary_item.html" with title='Alternative domains' value=DomainRequest.alternative_domains.all list='true' heading_level=heading_level %} + {% endif %} + + {% if DomainRequest.purpose %} + {% include "includes/summary_item.html" with title='Purpose of your domain' value=DomainRequest.purpose heading_level=heading_level %} + {% endif %} + + {% if DomainRequest.creator %} + {% include "includes/summary_item.html" with title='Your contact information' value=DomainRequest.creator contact='true' heading_level=heading_level %} + {% endif %} + + {% 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 %} + {% else %} + {% include "includes/summary_item.html" with title='Other employees from your organization' value=DomainRequest.no_other_contacts_rationale heading_level=heading_level %} + {% endif %} + + {# We always show this field even if None #} + {% if DomainRequest %} +

CISA Regional Representative

+
    + {% if DomainRequest.cisa_representative_first_name %} + {{ DomainRequest.get_formatted_cisa_rep_name }} + {% else %} + No + {% endif %} +
+

Anything else

+
    + {% if DomainRequest.anything_else %} + {{DomainRequest.anything_else}} + {% else %} + No + {% endif %} +
+ {% endif %} + {% endwith %} + {% endblock request_summary%} +
+
\ No newline at end of file diff --git a/src/registrar/templates/portfolio_domain_request_status_viewonly.html b/src/registrar/templates/portfolio_domain_request_status_viewonly.html new file mode 100644 index 000000000..0378d1b56 --- /dev/null +++ b/src/registrar/templates/portfolio_domain_request_status_viewonly.html @@ -0,0 +1,9 @@ +{% extends 'base.html' %} +{% load custom_filters %} +{% load static url_helpers %} + +{% block title %}Domain request status | {{ DomainRequest.requested_domain.name }} | {% endblock %} + +{% block content %} + {% include "includes/portfolio_request_status_view.html" %} +{% endblock %} diff --git a/src/registrar/tests/test_models.py b/src/registrar/tests/test_models.py index a6e889503..a6cac1389 100644 --- a/src/registrar/tests/test_models.py +++ b/src/registrar/tests/test_models.py @@ -114,6 +114,54 @@ class TestDomainRequest(TestCase): with less_console_noise(): return self.assertRaises(Exception, None, exception_type) + @less_console_noise_decorator + def test_request_is_withdrawable(self): + """Tests the is_withdrawable function""" + domain_request_1 = completed_domain_request( + status=DomainRequest.DomainRequestStatus.SUBMITTED, + name="city2.gov", + ) + domain_request_2 = completed_domain_request( + status=DomainRequest.DomainRequestStatus.IN_REVIEW, + name="city3.gov", + ) + domain_request_3 = completed_domain_request( + status=DomainRequest.DomainRequestStatus.ACTION_NEEDED, + name="city4.gov", + ) + domain_request_4 = completed_domain_request( + status=DomainRequest.DomainRequestStatus.REJECTED, + name="city5.gov", + ) + self.assertTrue(domain_request_1.is_withdrawable()) + self.assertTrue(domain_request_2.is_withdrawable()) + self.assertTrue(domain_request_3.is_withdrawable()) + self.assertFalse(domain_request_4.is_withdrawable()) + + @less_console_noise_decorator + def test_request_is_awaiting_review(self): + """Tests the is_awaiting_review function""" + domain_request_1 = completed_domain_request( + status=DomainRequest.DomainRequestStatus.SUBMITTED, + name="city2.gov", + ) + domain_request_2 = completed_domain_request( + status=DomainRequest.DomainRequestStatus.IN_REVIEW, + name="city3.gov", + ) + domain_request_3 = completed_domain_request( + status=DomainRequest.DomainRequestStatus.ACTION_NEEDED, + name="city4.gov", + ) + domain_request_4 = completed_domain_request( + status=DomainRequest.DomainRequestStatus.REJECTED, + name="city5.gov", + ) + self.assertTrue(domain_request_1.is_awaiting_review()) + self.assertTrue(domain_request_2.is_awaiting_review()) + self.assertFalse(domain_request_3.is_awaiting_review()) + self.assertFalse(domain_request_4.is_awaiting_review()) + @less_console_noise_decorator def test_federal_agency_set_to_non_federal_on_approve(self): """Ensures that when the federal_agency field is 'none' when .approve() is called, diff --git a/src/registrar/tests/test_views_request.py b/src/registrar/tests/test_views_request.py index 2cb3a381c..8530859e2 100644 --- a/src/registrar/tests/test_views_request.py +++ b/src/registrar/tests/test_views_request.py @@ -3025,3 +3025,40 @@ class TestWizardUnlockingSteps(TestWithUser, WebTest): else: self.fail(f"Expected a redirect, but got a different response: {response}") + + +class TestPortfolioDomainRequestViewonly(TestWithUser, WebTest): + + # Doesn't work with CSRF checking + # hypothesis is that CSRF_USE_SESSIONS is incompatible with WebTest + csrf_checks = False + + def setUp(self): + super().setUp() + self.federal_agency, _ = FederalAgency.objects.get_or_create(agency="General Services Administration") + self.app.set_user(self.user.username) + self.TITLES = DomainRequestWizard.TITLES + + def tearDown(self): + super().tearDown() + DomainRequest.objects.all().delete() + DomainInformation.objects.all().delete() + self.federal_agency.delete() + + @less_console_noise_decorator + @override_flag("organization_feature", active=True) + def test_domain_request_viewonly_displays_correct_fields(self): + """Tests that the viewonly page displays different fields""" + portfolio, _ = Portfolio.objects.get_or_create(creator=self.user, organization_name="Test Portfolio") + UserPortfolioPermission.objects.get_or_create( + user=self.user, portfolio=portfolio, roles=[UserPortfolioRoleChoices.ORGANIZATION_ADMIN] + ) + dummy_user, _ = User.objects.get_or_create(username="testusername123456") + domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.SUBMITTED, user=dummy_user) + domain_request.save() + + detail_page = self.app.get(f"/domain-request/viewonly/{domain_request.id}") + self.assertContains(detail_page, "Requesting entity") + self.assertNotContains(detail_page, "Type of organization") + self.assertContains(detail_page, "city.gov") + self.assertContains(detail_page, "Status:") diff --git a/src/registrar/tests/test_views_requests_json.py b/src/registrar/tests/test_views_requests_json.py index c6eb8a1dc..28e2a9407 100644 --- a/src/registrar/tests/test_views_requests_json.py +++ b/src/registrar/tests/test_views_requests_json.py @@ -341,7 +341,9 @@ class GetRequestsJsonTest(TestWithUser, WebTest): if creator[i] != self.user.email: # Test case where action is View self.assertEqual("View", action_labels[i]) - self.assertEqual("#", action_urls[i]) + self.assertEqual( + reverse("domain-request-status-viewonly", kwargs={"pk": expected_domain_request.id}), action_urls[i] + ) self.assertEqual("visibility", svg_icons[i]) elif status[i] in [ DomainRequest.DomainRequestStatus.STARTED.label, diff --git a/src/registrar/utility/enums.py b/src/registrar/utility/enums.py index 706eee1fc..b4fc5ed6f 100644 --- a/src/registrar/utility/enums.py +++ b/src/registrar/utility/enums.py @@ -1,6 +1,7 @@ """Used for holding various enums""" from enum import Enum +from registrar.utility import StrEnum class ValidationReturnType(Enum): @@ -38,3 +39,45 @@ 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.) + """ + + # 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" + + +class PortfolioDomainRequestStep(StrEnum): + """ + Names for each page of the portfolio domain request wizard. + + As with Django's own `TextChoices` class, steps will + appear in the order they are defined. (Order matters.) + """ + + # Portfolio + REQUESTING_ENTITY = "organization_name" + CURRENT_SITES = "current_sites" + DOTGOV_DOMAIN = "dotgov_domain" + PURPOSE = "purpose" + ADDITIONAL_DETAILS = "additional_details" + REQUIREMENTS = "requirements" diff --git a/src/registrar/views/domain_request.py b/src/registrar/views/domain_request.py index 92e1b939e..b7462f300 100644 --- a/src/registrar/views/domain_request.py +++ b/src/registrar/views/domain_request.py @@ -7,48 +7,25 @@ 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, PortfolioDomainRequestStep from .utility import ( DomainRequestPermissionView, DomainRequestPermissionWithdrawView, DomainRequestWizardPermissionView, + DomainRequestPortfolioViewonlyView, ) 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): """ A common set of methods and configuration. @@ -66,6 +43,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView): although not without consulting the base implementation, first. """ + StepEnum: Step = Step # type: ignore template_name = "" # uniquely namespace the wizard in urls.py @@ -78,29 +56,29 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView): NEW_URL_NAME = "/request/" # We need to pass our human-readable step titles as context to the templates. TITLES = { - Step.ORGANIZATION_TYPE: _("Type of organization"), - Step.TRIBAL_GOVERNMENT: _("Tribal government"), - Step.ORGANIZATION_FEDERAL: _("Federal government branch"), - Step.ORGANIZATION_ELECTION: _("Election office"), - Step.ORGANIZATION_CONTACT: _("Organization"), - Step.ABOUT_YOUR_ORGANIZATION: _("About your organization"), - Step.SENIOR_OFFICIAL: _("Senior official"), - Step.CURRENT_SITES: _("Current websites"), - Step.DOTGOV_DOMAIN: _(".gov domain"), - Step.PURPOSE: _("Purpose of your domain"), - Step.OTHER_CONTACTS: _("Other employees from your organization"), - Step.ADDITIONAL_DETAILS: _("Additional details"), - Step.REQUIREMENTS: _("Requirements for operating a .gov domain"), - Step.REVIEW: _("Review and submit your domain request"), + StepEnum.ORGANIZATION_TYPE: _("Type of organization"), + StepEnum.TRIBAL_GOVERNMENT: _("Tribal government"), + StepEnum.ORGANIZATION_FEDERAL: _("Federal government branch"), + StepEnum.ORGANIZATION_ELECTION: _("Election office"), + StepEnum.ORGANIZATION_CONTACT: _("Organization"), + StepEnum.ABOUT_YOUR_ORGANIZATION: _("About your organization"), + StepEnum.SENIOR_OFFICIAL: _("Senior official"), + StepEnum.CURRENT_SITES: _("Current websites"), + StepEnum.DOTGOV_DOMAIN: _(".gov domain"), + StepEnum.PURPOSE: _("Purpose of your domain"), + StepEnum.OTHER_CONTACTS: _("Other employees from your organization"), + StepEnum.ADDITIONAL_DETAILS: _("Additional details"), + StepEnum.REQUIREMENTS: _("Requirements for operating a .gov domain"), + StepEnum.REVIEW: _("Review and submit your domain request"), } # We can use a dictionary with step names and callables that return booleans # to show or hide particular steps based on the state of the process. WIZARD_CONDITIONS = { - Step.ORGANIZATION_FEDERAL: lambda w: w.from_model("show_organization_federal", False), - Step.TRIBAL_GOVERNMENT: lambda w: w.from_model("show_tribal_government", False), - Step.ORGANIZATION_ELECTION: lambda w: w.from_model("show_organization_election", False), - Step.ABOUT_YOUR_ORGANIZATION: lambda w: w.from_model("show_about_your_organization", False), + StepEnum.ORGANIZATION_FEDERAL: lambda w: w.from_model("show_organization_federal", False), + StepEnum.TRIBAL_GOVERNMENT: lambda w: w.from_model("show_tribal_government", False), + StepEnum.ORGANIZATION_ELECTION: lambda w: w.from_model("show_organization_election", False), + StepEnum.ABOUT_YOUR_ORGANIZATION: lambda w: w.from_model("show_about_your_organization", False), } def __init__(self): @@ -439,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": @@ -529,6 +499,26 @@ 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): + StepEnum: PortfolioDomainRequestStep = PortfolioDomainRequestStep # type: ignore + + TITLES = { + StepEnum.REQUESTING_ENTITY: _("Requesting entity"), + StepEnum.CURRENT_SITES: _("Current websites"), + StepEnum.DOTGOV_DOMAIN: _(".gov domain"), + StepEnum.PURPOSE: _("Purpose of your domain"), + StepEnum.ADDITIONAL_DETAILS: _("Additional details"), + StepEnum.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] @@ -750,6 +740,21 @@ class Finished(DomainRequestWizard): class DomainRequestStatus(DomainRequestPermissionView): template_name = "domain_request_status.html" + def has_permission(self): + """ + Override of the base has_permission class to account for portfolio permissions + """ + has_base_perms = super().has_permission() + if not has_base_perms: + return False + + if self.request.user.is_org_user(self.request): + portfolio = self.request.session.get("portfolio") + if not self.request.user.has_edit_request_portfolio_permission(portfolio): + return False + + return True + class DomainRequestWithdrawConfirmation(DomainRequestPermissionWithdrawView): """This page will ask user to confirm if they want to withdraw @@ -883,3 +888,21 @@ class DomainRequestDeleteView(DomainRequestPermissionDeleteView): duplicates = [item for item, count in object_dict.items() if count > 1] return duplicates + + +# region Portfolio views +class PortfolioDomainRequestStatusViewOnly(DomainRequestPortfolioViewonlyView): + template_name = "portfolio_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"] = wizard.StepEnum.__members__ + context["steps"] = request_step_list(wizard) + context["form_titles"] = wizard.TITLES + return context + + +# endregion diff --git a/src/registrar/views/domain_requests_json.py b/src/registrar/views/domain_requests_json.py index abaf029f2..d0e673adf 100644 --- a/src/registrar/views/domain_requests_json.py +++ b/src/registrar/views/domain_requests_json.py @@ -146,7 +146,7 @@ def serialize_domain_request(request, domain_request, user): action_url_map = { "Edit": reverse("edit-domain-request", kwargs={"id": domain_request.id}), "Manage": reverse("domain-request-status", kwargs={"pk": domain_request.id}), - "View": "#", + "View": reverse("domain-request-status-viewonly", kwargs={"pk": domain_request.id}), } svg_icon_map = {"Edit": "edit", "Manage": "settings", "View": "visibility"} diff --git a/src/registrar/views/utility/__init__.py b/src/registrar/views/utility/__init__.py index 7e4e19085..bb135b3d3 100644 --- a/src/registrar/views/utility/__init__.py +++ b/src/registrar/views/utility/__init__.py @@ -8,5 +8,6 @@ from .permission_views import ( DomainInvitationPermissionDeleteView, DomainRequestWizardPermissionView, PortfolioMembersPermission, + DomainRequestPortfolioViewonlyView, ) from .api_views import get_senior_official_from_federal_agency_json diff --git a/src/registrar/views/utility/mixins.py b/src/registrar/views/utility/mixins.py index 4552008de..d8c48e01e 100644 --- a/src/registrar/views/utility/mixins.py +++ b/src/registrar/views/utility/mixins.py @@ -289,6 +289,29 @@ class DomainRequestPermission(PermissionsLoginMixin): return True +class DomainRequestPortfolioViewonlyPermission(PermissionsLoginMixin): + """Permission mixin that redirects to domain request if user + has access, otherwise 403""" + + def has_permission(self): + """Check if this user has access to this domain request. + + The user is in self.request.user and the domain needs to be looked + up from the domain's primary key in self.kwargs["pk"] + """ + if not self.request.user.is_authenticated: + return False + + if not self.request.user.is_org_user(self.request): + return False + + portfolio = self.request.session.get("portfolio") + if not self.request.user.has_view_all_requests_portfolio_permission(portfolio): + return False + + return True + + class UserDeleteDomainRolePermission(PermissionsLoginMixin): """Permission mixin for UserDomainRole if user has access, otherwise 403""" diff --git a/src/registrar/views/utility/permission_views.py b/src/registrar/views/utility/permission_views.py index e7031cf0d..414e58275 100644 --- a/src/registrar/views/utility/permission_views.py +++ b/src/registrar/views/utility/permission_views.py @@ -19,6 +19,7 @@ from .mixins import ( UserProfilePermission, PortfolioBasePermission, PortfolioMembersPermission, + DomainRequestPortfolioViewonlyPermission, ) import logging @@ -100,6 +101,25 @@ class DomainRequestPermissionView(DomainRequestPermission, DetailView, abc.ABC): raise NotImplementedError +class DomainRequestPortfolioViewonlyView(DomainRequestPortfolioViewonlyPermission, DetailView, abc.ABC): + """Abstract base view for domain requests that enforces permissions + + This abstract view cannot be instantiated. Actual views must specify + `template_name`. + """ + + # DetailView property for what model this is viewing + model = DomainRequest + # variable name in template context for the model object + context_object_name = "DomainRequest" + + # Abstract property enforces NotImplementedError on an attribute. + @property + @abc.abstractmethod + def template_name(self): + raise NotImplementedError + + class DomainRequestPermissionWithdrawView(DomainRequestPermissionWithdraw, DetailView, abc.ABC): """Abstract base view for domain request withdraw function