Last updated: {{DomainRequest.updated_at|date:"F j, Y"}}
-
+
+ {% if DomainRequest.creator and DomainRequest.creator != request.user %}
+
+ Created by: {{DomainRequest.creator.email|default:DomainRequest.creator.get_formatted_name }}
+
+ {% 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" %}
+ {% 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 %}
+
+ Started on: {{DomainRequest.last_status_update|date:"F j, Y"}}
+
- {% if domain_request.cisa_representative_first_name %}
- {{domain_request.cisa_representative_first_name}} {{domain_request.cisa_representative_last_name}}
+ {% if DomainRequest.cisa_representative_first_name %}
+ {{ DomainRequest.get_formatted_cisa_rep_name }}
{% else %}
No
{% endif %}
From e5a011c03954b3db3de87bc54ad394dbf8622d63 Mon Sep 17 00:00:00 2001
From: zandercymatics <141044360+zandercymatics@users.noreply.github.com>
Date: Fri, 13 Sep 2024 12:06:45 -0600
Subject: [PATCH 02/14] tweaks + cleanup on normal view
---
src/registrar/models/domain_request.py | 13 ++++++++++
.../templates/domain_request_status.html | 24 +++++++++++++++----
2 files changed, 32 insertions(+), 5 deletions(-)
diff --git a/src/registrar/models/domain_request.py b/src/registrar/models/domain_request.py
index 9817824b89..865d4fec8a 100644
--- a/src/registrar/models/domain_request.py
+++ b/src/registrar/models/domain_request.py
@@ -12,6 +12,7 @@
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 @@ def get_action_needed_reason_label(cls, action_needed_reason: str):
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 f5519b6bea..f5119e1afc 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 }}
+ {% else %}
+ {% comment %} Question: What do we do in this case???? {% endcomment %}
+
Domain request for [UNKNOWN]
+ {% endif %}
Domain request for {{ DomainRequest.requested_domain.name }}
{% 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}}
+ {% if not DomainRequest.requested_domain and DomainRequest.status == DomainRequest.DomainRequestStatus.STARTED %}
+
New domain request
{% else %}
- {% comment %} Question: What do we do in this case???? {% endcomment %}
-
Domain request for [UNKNOWN]
+
Domain request for {{ DomainRequest.requested_domain.name }}
{% endif %}
Date: Mon, 16 Sep 2024 10:11:22 -0600
Subject: [PATCH 05/14] Fix url path bug
---
src/registrar/models/domain_request.py | 8 ++++--
.../models/utility/generic_helper.py | 19 +++++++++++++
.../templates/includes/header_extended.html | 6 ++--
src/registrar/templatetags/custom_filters.py | 28 +++++++++++++++++++
4 files changed, 55 insertions(+), 6 deletions(-)
diff --git a/src/registrar/models/domain_request.py b/src/registrar/models/domain_request.py
index 865d4fec8a..a6c7f7bc16 100644
--- a/src/registrar/models/domain_request.py
+++ b/src/registrar/models/domain_request.py
@@ -598,9 +598,11 @@ def get_action_needed_reason_label(cls, action_needed_reason: str):
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()
+ 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):
diff --git a/src/registrar/models/utility/generic_helper.py b/src/registrar/models/utility/generic_helper.py
index 8c44a3bdd9..3cafe87c4a 100644
--- a/src/registrar/models/utility/generic_helper.py
+++ b/src/registrar/models/utility/generic_helper.py
@@ -3,6 +3,7 @@
import time
import logging
from urllib.parse import urlparse, urlunparse, urlencode
+from django.urls import resolve, Resolver404
logger = logging.getLogger(__name__)
@@ -315,3 +316,21 @@ def convert_queryset_to_dict(queryset, is_model=True, key="id"):
request_dict = {value[key]: value for value in queryset}
return request_dict
+
+
+def get_url_name(path):
+ """
+ Given a URL path, returns the corresponding URL name defined in urls.py.
+
+ Args:
+ path (str): The URL path to resolve.
+
+ Returns:
+ str or None: The URL name if it exists, otherwise None.
+ """
+ try:
+ match = resolve(path)
+ return match.url_name
+ except Resolver404:
+ logger.error(f"No matching URL name found for path: {path}")
+ return None
diff --git a/src/registrar/templates/includes/header_extended.html b/src/registrar/templates/includes/header_extended.html
index ba6eef48aa..960d96bced 100644
--- a/src/registrar/templates/includes/header_extended.html
+++ b/src/registrar/templates/includes/header_extended.html
@@ -59,7 +59,7 @@
{% url 'domain-requests' as url %}
- {% if DomainRequest.creator and DomainRequest.creator != request.user %}
-
- Created by: {{DomainRequest.creator.email|default:DomainRequest.creator.get_formatted_name }}
-
- {% 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" last_status_update=DomainRequest.last_status_update|date:"F j, Y" %}
{% comment %}
These are intentionally seperated this way.
diff --git a/src/registrar/tests/test_views_request.py b/src/registrar/tests/test_views_request.py
index f3898df9c0..61fe8a41e0 100644
--- a/src/registrar/tests/test_views_request.py
+++ b/src/registrar/tests/test_views_request.py
@@ -1,6 +1,7 @@
from unittest import skip
-from unittest.mock import Mock
-
+from unittest.mock import Mock, patch
+from datetime import datetime
+from django.utils import timezone
from django.conf import settings
from django.urls import reverse
from api.tests.common import less_console_noise_decorator
@@ -55,6 +56,54 @@ def test_domain_request_form_intro_acknowledgement(self):
intro_page = self.app.get(reverse("domain-request:"))
self.assertContains(intro_page, "You’re about to start your .gov domain request")
+ @less_console_noise_decorator
+ def test_template_status_display(self):
+ """Tests the display of status-related information in the template."""
+ domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.SUBMITTED, user=self.user)
+ domain_request.last_submitted_date = datetime.now()
+ domain_request.save()
+ response = self.app.get(f"/domain-request/{domain_request.id}")
+ self.assertContains(response, "Submitted on:")
+ self.assertContains(response, domain_request.last_submitted_date.strftime("%B %-d, %Y"))
+
+ @patch.object(DomainRequest, "get_first_status_set_date")
+ def test_get_first_status_started_date(self, mock_get_first_status_set_date):
+ """Tests retrieval of the first date the status was set to 'started'."""
+
+ # Set the mock to return a fixed date
+ fixed_date = timezone.datetime(2023, 1, 1).date()
+ mock_get_first_status_set_date.return_value = fixed_date
+
+ domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.STARTED, user=self.user)
+ domain_request.last_status_update = None
+ domain_request.save()
+
+ response = self.app.get(f"/domain-request/{domain_request.id}")
+ # Ensure that the date is still set to None
+ self.assertIsNone(domain_request.last_status_update)
+ print(response)
+ # We should still grab a date for this field in this event - but it should come from the audit log instead
+ self.assertContains(response, "Started on:")
+ self.assertContains(response, fixed_date.strftime("%B %-d, %Y"))
+
+ # If a status date is set, we display that instead
+ domain_request.last_status_update = datetime.now()
+ domain_request.save()
+
+ response = self.app.get(f"/domain-request/{domain_request.id}")
+
+ # We should still grab a date for this field in this event - but it should come from the audit log instead
+ self.assertContains(response, "Started on:")
+ self.assertContains(response, domain_request.last_status_update.strftime("%B %-d, %Y"))
+
+ def test_template_new_domain_request_display(self):
+ """Tests the display of the new domain request header."""
+ domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.STARTED, user=self.user)
+ domain_request.requested_domain = None
+ domain_request.save()
+ response = self.app.get(f"/domain-request/{domain_request.id}")
+ self.assertContains(response, "New domain request")
+
@less_console_noise_decorator
def test_domain_request_form_intro_is_skipped_when_edit_access(self):
"""Tests that user is NOT presented with intro acknowledgement page when accessed through 'edit'"""
From 82c5d7f2dcb8d05eb846ba1624577b24dc8e781f Mon Sep 17 00:00:00 2001
From: zandercymatics <141044360+zandercymatics@users.noreply.github.com>
Date: Mon, 16 Sep 2024 11:15:01 -0600
Subject: [PATCH 07/14] Add additional subpage logic
---
.../templates/includes/header_extended.html | 4 +-
src/registrar/templatetags/custom_filters.py | 39 ++++++++++++++++++-
2 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/src/registrar/templates/includes/header_extended.html b/src/registrar/templates/includes/header_extended.html
index 960d96bced..5f8fe43716 100644
--- a/src/registrar/templates/includes/header_extended.html
+++ b/src/registrar/templates/includes/header_extended.html
@@ -42,7 +42,7 @@
{% else %}
{% url 'no-portfolio-domains' as url %}
{% endif %}
-
+
Domains
@@ -104,7 +104,7 @@