diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js
index f3b41eb51..70659b009 100644
--- a/src/registrar/assets/js/get-gov.js
+++ b/src/registrar/assets/js/get-gov.js
@@ -1599,7 +1599,7 @@ document.addEventListener('DOMContentLoaded', function() {
const domainName = request.requested_domain ? request.requested_domain : `New domain request
(${utcDateString(request.created_at)})`;
const actionUrl = request.action_url;
const actionLabel = request.action_label;
- const submissionDate = request.submission_date ? new Date(request.submission_date).toLocaleDateString('en-US', options) : `Not submitted`;
+ const submissionDate = request.last_submitted_date ? new Date(request.last_submitted_date).toLocaleDateString('en-US', options) : `Not submitted`;
// Even if the request is not deletable, we may need this empty string for the td if the deletable column is displayed
let modalTrigger = '';
@@ -1699,7 +1699,7 @@ document.addEventListener('DOMContentLoaded', function() {
${domainName}
|
-
+ |
${submissionDate}
|
diff --git a/src/registrar/management/commands/populate_domain_request_dates.py b/src/registrar/management/commands/populate_domain_request_dates.py
index 90fc06dcf..19d8e4f00 100644
--- a/src/registrar/management/commands/populate_domain_request_dates.py
+++ b/src/registrar/management/commands/populate_domain_request_dates.py
@@ -17,26 +17,26 @@ class Command(BaseCommand, PopulateScriptTemplate):
def update_record(self, record: DomainRequest):
"""Defines how we update the first_submitted_date and last_status_update fields"""
- try:
- # Retrieve and order audit log entries by timestamp in descending order
- audit_log_entries = LogEntry.objects.filter(object_pk=record.pk).order_by("-timestamp")
+
+ # Retrieve and order audit log entries by timestamp in descending order
+ audit_log_entries = LogEntry.objects.filter(object_pk=record.pk).order_by("-timestamp")
- # Loop through logs in descending order to find most recent status change
- for log_entry in audit_log_entries:
- if "status" in log_entry.changes:
- record.last_status_update = log_entry.timestamp.date()
- break
-
- # Loop through logs in ascending order to find first submission
- for log_entry in audit_log_entries.reverse():
- if log_entry.changes_dict['status'](1) == 'Submitted':
- record.first_submitted_date = log_entry.timestamp.date()
+ # Loop through logs in descending order to find most recent status change
+ for log_entry in audit_log_entries:
+ if 'status' in LogEntry.changes_dict:
+ record.last_status_update = log_entry.timestamp.date()
+ break
- except ObjectDoesNotExist as e:
- logger.error(f"Object with object_pk {record.pk} does not exist: {e}")
- except Exception as e:
- logger.error(f"An error occurred during update_record: {e}")
+ # Loop through logs in ascending order to find first submission
+ for log_entry in audit_log_entries.reverse():
+ if log_entry.changes_dict['status'](1) == 'Submitted':
+ record.first_submitted_date = log_entry.timestamp.date()
+ break
logger.info(
- f"{TerminalColors.OKCYAN}Updating {record} => first submitted date: " f"{record.first_submitted_date}{TerminalColors.OKCYAN}, last status update:" f"{record.last_status_update}{TerminalColors.OKCYAN}"
+ f"{TerminalColors.OKCYAN}Updating {record} => first submitted date: " f"{record.first_submitted_date}{TerminalColors.OKCYAN}, last status update:" f"{record.last_status_update}{TerminalColors.ENDC}"
)
+
+ def should_skip_record(self, record) -> bool:
+ # make sure the record had some kind of history
+ return LogEntry.objects.filter(object_pk=record.pk).exists()
diff --git a/src/registrar/migrations/0119_add_domainrequest_submission_dates.py b/src/registrar/migrations/0119_add_domainrequest_submission_dates.py
index 0b94e1257..ea209626e 100644
--- a/src/registrar/migrations/0119_add_domainrequest_submission_dates.py
+++ b/src/registrar/migrations/0119_add_domainrequest_submission_dates.py
@@ -35,7 +35,7 @@ class Migration(migrations.Migration):
field=models.DateField(
blank=True,
default=None,
- help_text="Date of last status updated",
+ help_text="Date of the last status update",
null=True,
verbose_name="last updated on",
),
diff --git a/src/registrar/models/domain_request.py b/src/registrar/models/domain_request.py
index 74d275d95..09f200793 100644
--- a/src/registrar/models/domain_request.py
+++ b/src/registrar/models/domain_request.py
@@ -563,7 +563,7 @@ class DomainRequest(TimeStampedModel):
help_text="Acknowledged .gov acceptable use policy",
)
- # initial submission date records when domain request was first submitted
+ # Records when the domain request was first submitted
first_submitted_date = models.DateField(
null=True,
blank=True,
@@ -572,7 +572,7 @@ class DomainRequest(TimeStampedModel):
help_text="Date initially submitted",
)
- # last submission date records when domain request was last submitted
+ # Records when domain request was last submitted
last_submitted_date = models.DateField(
null=True,
blank=True,
@@ -581,13 +581,13 @@ class DomainRequest(TimeStampedModel):
help_text="Date last submitted",
)
- # last status update records when domain request status was last updated by an admin or analyst
+ # Records when domain request status was last updated by an admin or analyst
last_status_update = models.DateField(
null=True,
blank=True,
default=None,
verbose_name="last updated on",
- help_text="Date of last status updated",
+ help_text="Date of the last status update",
)
notes = models.TextField(
null=True,
|