mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-17 10:07:04 +02:00
cleanup
This commit is contained in:
parent
3754e0b48b
commit
41748e59f5
3 changed files with 25 additions and 9 deletions
|
@ -1864,7 +1864,7 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
if status_changed:
|
if status_changed:
|
||||||
_, status_value = changes.get("status")
|
_, status_value = changes.get("status")
|
||||||
if status_value:
|
if status_value:
|
||||||
entry["status"] = DomainRequest.DomainRequestStatus(status_value).label
|
entry["status"] = DomainRequest.DomainRequestStatus.get_status_label(status_value)
|
||||||
|
|
||||||
# Handle rejection reason change
|
# Handle rejection reason change
|
||||||
if rejection_reason_changed:
|
if rejection_reason_changed:
|
||||||
|
@ -1873,11 +1873,13 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
entry["rejection_reason"] = (
|
entry["rejection_reason"] = (
|
||||||
""
|
""
|
||||||
if rejection_reason_value == "None"
|
if rejection_reason_value == "None"
|
||||||
else DomainRequest.RejectionReasons(rejection_reason_value).label
|
else DomainRequest.RejectionReasons.get_rejection_reason_label(rejection_reason_value)
|
||||||
)
|
)
|
||||||
# Handle case where rejection reason changed but not status
|
# Handle case where rejection reason changed but not status
|
||||||
if not status_changed:
|
if not status_changed:
|
||||||
entry["status"] = DomainRequest.DomainRequestStatus.REJECTED.label
|
entry["status"] = DomainRequest.DomainRequestStatus.get_status_label(
|
||||||
|
DomainRequest.DomainRequestStatus.REJECTED
|
||||||
|
)
|
||||||
|
|
||||||
# Handle action needed reason change
|
# Handle action needed reason change
|
||||||
if action_needed_reason_changed:
|
if action_needed_reason_changed:
|
||||||
|
@ -1886,11 +1888,15 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
entry["action_needed_reason"] = (
|
entry["action_needed_reason"] = (
|
||||||
""
|
""
|
||||||
if action_needed_reason_value == "None"
|
if action_needed_reason_value == "None"
|
||||||
else DomainRequest.ActionNeededReasons(action_needed_reason_value).label
|
else DomainRequest.ActionNeededReasons.get_action_needed_reason_label(
|
||||||
|
action_needed_reason_value
|
||||||
|
)
|
||||||
)
|
)
|
||||||
# Handle case where action needed reason changed but not status
|
# Handle case where action needed reason changed but not status
|
||||||
if not status_changed:
|
if not status_changed:
|
||||||
entry["status"] = DomainRequest.DomainRequestStatus.ACTION_NEEDED.label
|
entry["status"] = DomainRequest.DomainRequestStatus.get_status_label(
|
||||||
|
DomainRequest.DomainRequestStatus.ACTION_NEEDED
|
||||||
|
)
|
||||||
|
|
||||||
# Add actor and timestamp information
|
# Add actor and timestamp information
|
||||||
entry["actor"] = log_entry.actor
|
entry["actor"] = log_entry.actor
|
||||||
|
|
|
@ -256,6 +256,11 @@ class DomainRequest(TimeStampedModel):
|
||||||
NAMING_REQUIREMENTS = "naming_not_met", "Naming requirements not met"
|
NAMING_REQUIREMENTS = "naming_not_met", "Naming requirements not met"
|
||||||
OTHER = "other", "Other/Unspecified"
|
OTHER = "other", "Other/Unspecified"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_rejection_reason_label(cls, rejection_reason: str):
|
||||||
|
"""Returns the associated label for a given rejection reason"""
|
||||||
|
return cls(rejection_reason).label if rejection_reason else None
|
||||||
|
|
||||||
class ActionNeededReasons(models.TextChoices):
|
class ActionNeededReasons(models.TextChoices):
|
||||||
"""Defines common action needed reasons for domain requests"""
|
"""Defines common action needed reasons for domain requests"""
|
||||||
|
|
||||||
|
@ -265,6 +270,11 @@ class DomainRequest(TimeStampedModel):
|
||||||
BAD_NAME = ("bad_name", "Doesn’t meet naming requirements")
|
BAD_NAME = ("bad_name", "Doesn’t meet naming requirements")
|
||||||
OTHER = ("other", "Other (no auto-email sent)")
|
OTHER = ("other", "Other (no auto-email sent)")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_action_needed_reason_label(cls, action_needed_reason: str):
|
||||||
|
"""Returns the associated label for a given action needed reason"""
|
||||||
|
return cls(action_needed_reason).label if action_needed_reason else None
|
||||||
|
|
||||||
# #### Internal fields about the domain request #####
|
# #### Internal fields about the domain request #####
|
||||||
status = FSMField(
|
status = FSMField(
|
||||||
choices=DomainRequestStatus.choices, # possible states as an array of constants
|
choices=DomainRequestStatus.choices, # possible states as an array of constants
|
||||||
|
|
|
@ -86,20 +86,20 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
{% if entry.status %}
|
{% if entry.status %}
|
||||||
{{ entry.status|default:"None" }}
|
{{ entry.status|default:"Error" }}
|
||||||
{% else %}
|
{% else %}
|
||||||
Error
|
Error
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if entry.rejection_reason %}
|
{% if entry.rejection_reason %}
|
||||||
- {{ entry.rejection_reason|default:"None" }}
|
- {{ entry.rejection_reason|default:"Error" }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if entry.action_needed_reason %}
|
{% if entry.action_needed_reason %}
|
||||||
- {{ entry.action_needed_reason|default:"None" }}
|
- {{ entry.action_needed_reason|default:"Error" }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>{{ entry.actor|default:"None" }}</td>
|
<td>{{ entry.actor|default:"Error" }}</td>
|
||||||
<td>{{ entry.timestamp|date:"Y-m-d H:i:s" }}</td>
|
<td>{{ entry.timestamp|date:"Y-m-d H:i:s" }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue