mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-17 18:09:25 +02:00
small cleanup
This commit is contained in:
parent
8644b0d456
commit
a3fa71659a
3 changed files with 17 additions and 22 deletions
|
@ -50,25 +50,11 @@ class DomainRequest(TimeStampedModel):
|
||||||
def get_status_label(cls, status_name: str):
|
def get_status_label(cls, status_name: str):
|
||||||
"""Returns the associated label for a given status name"""
|
"""Returns the associated label for a given status name"""
|
||||||
return cls(status_name).label if status_name else None
|
return cls(status_name).label if status_name else None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def statuses_awaiting_review(cls):
|
def statuses_awaiting_review(cls):
|
||||||
"""Returns all statuses that are awaiting a review from analysts"""
|
"""Returns all statuses that are awaiting a review from analysts"""
|
||||||
return [
|
return [cls.SUBMITTED, cls.IN_REVIEW]
|
||||||
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):
|
class StateTerritoryChoices(models.TextChoices):
|
||||||
ALABAMA = "AL", "Alabama (AL)"
|
ALABAMA = "AL", "Alabama (AL)"
|
||||||
|
@ -606,10 +592,6 @@ class DomainRequest(TimeStampedModel):
|
||||||
"""Checks if the current status is in submitted or in_review"""
|
"""Checks if the current status is in submitted or in_review"""
|
||||||
return self.status in DomainRequest.DomainRequestStatus.statuses_awaiting_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):
|
def get_first_status_set_date(self, status):
|
||||||
"""Returns the date when the domain request was first set to the given status."""
|
"""Returns the date when the domain request was first set to the given status."""
|
||||||
log_entry = (
|
log_entry = (
|
||||||
|
@ -1028,6 +1010,17 @@ class DomainRequest(TimeStampedModel):
|
||||||
send_email=send_email,
|
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(
|
@transition(
|
||||||
field="status",
|
field="status",
|
||||||
source=[DomainRequestStatus.SUBMITTED, DomainRequestStatus.IN_REVIEW, DomainRequestStatus.ACTION_NEEDED],
|
source=[DomainRequestStatus.SUBMITTED, DomainRequestStatus.IN_REVIEW, DomainRequestStatus.ACTION_NEEDED],
|
||||||
|
|
|
@ -341,7 +341,9 @@ class GetRequestsJsonTest(TestWithUser, WebTest):
|
||||||
if creator[i] != self.user.email:
|
if creator[i] != self.user.email:
|
||||||
# Test case where action is View
|
# Test case where action is View
|
||||||
self.assertEqual("View", action_labels[i])
|
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])
|
self.assertEqual("visibility", svg_icons[i])
|
||||||
elif status[i] in [
|
elif status[i] in [
|
||||||
DomainRequest.DomainRequestStatus.STARTED.label,
|
DomainRequest.DomainRequestStatus.STARTED.label,
|
||||||
|
|
|
@ -758,7 +758,7 @@ class DomainRequestStatus(DomainRequestPermissionView):
|
||||||
has_base_perms = super().has_permission()
|
has_base_perms = super().has_permission()
|
||||||
if not has_base_perms:
|
if not has_base_perms:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if self.request.user.is_org_user(self.request):
|
if self.request.user.is_org_user(self.request):
|
||||||
portfolio = self.request.session.get("portfolio")
|
portfolio = self.request.session.get("portfolio")
|
||||||
if not self.request.user.has_edit_request_portfolio_permission(portfolio):
|
if not self.request.user.has_edit_request_portfolio_permission(portfolio):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue