Merge remote-tracking branch 'origin/main' into nl/2248-add-org-and-portfolio-table

This commit is contained in:
CocoByte 2024-06-17 11:06:42 -06:00
commit c7f7898d04
No known key found for this signature in database
GPG key ID: BBFAA2526384C97F
20 changed files with 885 additions and 260 deletions

View file

@ -17,8 +17,6 @@ from .utility.time_stamped_model import TimeStampedModel
from ..utility.email import send_templated_email, EmailSendingError
from itertools import chain
from auditlog.models import AuditlogHistoryField # type: ignore
logger = logging.getLogger(__name__)
@ -35,11 +33,7 @@ class DomainRequest(TimeStampedModel):
]
# https://django-auditlog.readthedocs.io/en/latest/usage.html#object-history
# If we note any performace degradation due to this addition,
# we can query the auditlogs table in admin.py and add the results to
# extra_context in the change_view method for DomainRequestAdmin.
# This is the more straightforward way so trying it first.
history = AuditlogHistoryField()
# history = AuditlogHistoryField()
# Constants for choice fields
class DomainRequestStatus(models.TextChoices):
@ -262,6 +256,11 @@ class DomainRequest(TimeStampedModel):
NAMING_REQUIREMENTS = "naming_not_met", "Naming requirements not met"
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):
"""Defines common action needed reasons for domain requests"""
@ -271,6 +270,11 @@ class DomainRequest(TimeStampedModel):
BAD_NAME = ("bad_name", "Doesnt meet naming requirements")
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 #####
status = FSMField(
choices=DomainRequestStatus.choices, # possible states as an array of constants