diff --git a/src/registrar/models/domain_request.py b/src/registrar/models/domain_request.py index 9817824b8..865d4fec8 100644 --- a/src/registrar/models/domain_request.py +++ b/src/registrar/models/domain_request.py @@ -12,6 +12,7 @@ from registrar.models.federal_agency import FederalAgency from registrar.models.utility.generic_helper import CreateOrUpdateOrganizationTypeHelper from registrar.utility.errors import FSMDomainRequestError, FSMErrorCodes from registrar.utility.constants import BranchChoices +from auditlog.models import LogEntry from .utility.time_stamped_model import TimeStampedModel from ..utility.email import send_templated_email, EmailSendingError @@ -589,11 +590,23 @@ class DomainRequest(TimeStampedModel): verbose_name="last updated on", help_text="Date of the last status update", ) + notes = models.TextField( null=True, blank=True, ) + def get_first_status_set_date(self, status): + """Returns the date when the domain request was first set to the given status.""" + log_entry = LogEntry.objects.filter( + content_type__model="domainrequest", object_pk=self.pk, changes__status__1=status + ).order_by("-timestamp").first() + return log_entry.timestamp.date() if log_entry else None + + def get_first_status_started_date(self): + """Returns the date when the domain request was put into the status "started" for the first time""" + return self.get_first_status_set_date(DomainRequest.DomainRequestStatus.STARTED) + @classmethod def get_statuses_that_send_emails(cls): """Returns a list of statuses that send an email to the user""" diff --git a/src/registrar/templates/domain_request_status.html b/src/registrar/templates/domain_request_status.html index f5519b6be..f5119e1af 100644 --- a/src/registrar/templates/domain_request_status.html +++ b/src/registrar/templates/domain_request_status.html @@ -34,8 +34,15 @@ Back to manage your domains

- {% comment %} {% endif %}{% endcomment %} + + {% if DomainRequest.requested_domain %}

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

+ {% elif DomainRequest.status == DomainRequest.DomainRequestStatus.STARTED %} +

New domain request

+ {% else %} + {% comment %} Question: What do we do in this case???? {% endcomment %} +

Domain request for [UNKNOWN]

+ {% 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" %} + {% 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" %}

- Started on: {{DomainRequest.last_status_update|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 }} @@ -89,14 +103,14 @@ Submitted on: {{last_submitted|default:first_submitted }}

- Rejected on: {{DomainRequest.last_status_update|date:"F j, Y"}} + Rejected on: {{last_status_update}}

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

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

- Withdrawn on: {{DomainRequest.last_status_update|date:"F j, Y"}} + Withdrawn on: {{last_status_update}}

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