mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-17 18:09:25 +02:00
Consolidate checks on withdrawable and awaiting review
This commit is contained in:
parent
732c982caa
commit
81c27330b2
6 changed files with 44 additions and 7 deletions
|
@ -51,6 +51,25 @@ class DomainRequest(TimeStampedModel):
|
|||
"""Returns the associated label for a given status name"""
|
||||
return cls(status_name).label if status_name else None
|
||||
|
||||
@classmethod
|
||||
def statuses_awaiting_review(cls):
|
||||
"""Returns all statuses that are awaiting a review from analysts"""
|
||||
return [
|
||||
cls.SUBMITTED,
|
||||
cls.IN_REVIEW
|
||||
]
|
||||
|
||||
# TODO - a better approach might be to just grab the value of source?
|
||||
# How??
|
||||
@classmethod
|
||||
def withdrawable_statuses(cls):
|
||||
"""Returns all statuses that are withdrawable"""
|
||||
return [
|
||||
cls.SUBMITTED,
|
||||
cls.IN_REVIEW,
|
||||
cls.ACTION_NEEDED
|
||||
]
|
||||
|
||||
class StateTerritoryChoices(models.TextChoices):
|
||||
ALABAMA = "AL", "Alabama (AL)"
|
||||
ALASKA = "AK", "Alaska (AK)"
|
||||
|
@ -583,6 +602,14 @@ 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 DomainRequest.DomainRequestStatus.statuses_awaiting_review()
|
||||
|
||||
def is_withdrawable(self):
|
||||
"""Helper function that determines if the request can be withdrawn in its current status"""
|
||||
return self.status in DomainRequest.DomainRequestStatus.withdrawable_statuses()
|
||||
|
||||
def get_first_status_set_date(self, status):
|
||||
"""Returns the date when the domain request was first set to the given status."""
|
||||
log_entry = (
|
||||
|
|
|
@ -9,4 +9,6 @@
|
|||
Need to make changes?
|
||||
</h2>
|
||||
|
||||
<p>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.</p>
|
||||
{% if show_withdraw_text %}
|
||||
<p>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.</p>
|
||||
{% endif %}
|
|
@ -125,13 +125,13 @@
|
|||
{% endblock status_metadata %}
|
||||
|
||||
{% block status_blurb %}
|
||||
{% if DomainRequest.status == 'submitted' %}
|
||||
<p>{% include "includes/domain_request.html" %}</p>
|
||||
{% if DomainRequest.is_withdrawable %}
|
||||
<p>{% include "includes/domain_request_awaiting_review.html" with show_withdraw_text=True %}</p>
|
||||
{% endif %}
|
||||
{% endblock status_blurb %}
|
||||
|
||||
{% block modify_request %}
|
||||
{% if DomainRequest.status != "started" and DomainRequest.status != 'withdrawn' and DomainRequest.status != 'rejected' %}
|
||||
{% if DomainRequest.is_withdrawable %}
|
||||
<p><a href="{% url 'domain-request-withdraw-confirmation' pk=DomainRequest.id %}" class="usa-button usa-button--outline withdraw_outline">
|
||||
Withdraw request</a>
|
||||
</p>
|
||||
|
|
|
@ -2,6 +2,13 @@
|
|||
{% load custom_filters %}
|
||||
{% load static url_helpers %}
|
||||
|
||||
{% comment %} Do not show the withdraw button {% endcomment %}
|
||||
{% comment %} Do not show the withdrawal text in viewonly mode {% endcomment %}
|
||||
{% block status_blurb %}
|
||||
{% if DomainRequest.is_awaiting_review %}
|
||||
<p>{% include "includes/domain_request_awaiting_review.html" with show_withdraw_text=False %}</p>
|
||||
{% endif %}
|
||||
{% endblock status_blurb %}
|
||||
|
||||
{% comment %} Do not show action buttons in viewonly mode {% endcomment %}
|
||||
{% block modify_request %}
|
||||
{% endblock modify_request %}
|
||||
|
|
|
@ -2238,11 +2238,11 @@ class TestDomainRequestIncomplete(TestCase):
|
|||
|
||||
@less_console_noise_decorator
|
||||
def test_is_organization_name_and_address_complete(self):
|
||||
self.assertTrue(self.domain_request._is_organization_name_and_address_complete())
|
||||
self.assertTrue(self.domain_request.is_organization_name_and_address_complete())
|
||||
self.domain_request.organization_name = None
|
||||
self.domain_request.address_line1 = None
|
||||
self.domain_request.save()
|
||||
self.assertTrue(self.domain_request._is_organization_name_and_address_complete())
|
||||
self.assertTrue(self.domain_request.is_organization_name_and_address_complete())
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_is_senior_official_complete(self):
|
||||
|
|
|
@ -750,6 +750,7 @@ 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue