mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-18 02:19:23 +02:00
review changes
This commit is contained in:
parent
08c42a6e8d
commit
62ac4757ec
4 changed files with 25 additions and 25 deletions
|
@ -1599,7 +1599,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
const domainName = request.requested_domain ? request.requested_domain : `New domain request <br><span class="text-base font-body-xs">(${utcDateString(request.created_at)})</span>`;
|
const domainName = request.requested_domain ? request.requested_domain : `New domain request <br><span class="text-base font-body-xs">(${utcDateString(request.created_at)})</span>`;
|
||||||
const actionUrl = request.action_url;
|
const actionUrl = request.action_url;
|
||||||
const actionLabel = request.action_label;
|
const actionLabel = request.action_label;
|
||||||
const submissionDate = request.submission_date ? new Date(request.submission_date).toLocaleDateString('en-US', options) : `<span class="text-base">Not submitted</span>`;
|
const submissionDate = request.last_submitted_date ? new Date(request.last_submitted_date).toLocaleDateString('en-US', options) : `<span class="text-base">Not submitted</span>`;
|
||||||
|
|
||||||
// Even if the request is not deletable, we may need this empty string for the td if the deletable column is displayed
|
// Even if the request is not deletable, we may need this empty string for the td if the deletable column is displayed
|
||||||
let modalTrigger = '';
|
let modalTrigger = '';
|
||||||
|
@ -1699,7 +1699,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
<th scope="row" role="rowheader" data-label="Domain name">
|
<th scope="row" role="rowheader" data-label="Domain name">
|
||||||
${domainName}
|
${domainName}
|
||||||
</th>
|
</th>
|
||||||
<td data-sort-value="${new Date(request.submission_date).getTime()}" data-label="Date submitted">
|
<td data-sort-value="${new Date(request.last_submitted_date).getTime()}" data-label="Date submitted">
|
||||||
${submissionDate}
|
${submissionDate}
|
||||||
</td>
|
</td>
|
||||||
<td data-label="Status">
|
<td data-label="Status">
|
||||||
|
|
|
@ -17,26 +17,26 @@ class Command(BaseCommand, PopulateScriptTemplate):
|
||||||
|
|
||||||
def update_record(self, record: DomainRequest):
|
def update_record(self, record: DomainRequest):
|
||||||
"""Defines how we update the first_submitted_date and last_status_update fields"""
|
"""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
|
# Retrieve and order audit log entries by timestamp in descending order
|
||||||
audit_log_entries = LogEntry.objects.filter(object_pk=record.pk).order_by("-timestamp")
|
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
|
# Loop through logs in descending order to find most recent status change
|
||||||
for log_entry in audit_log_entries:
|
for log_entry in audit_log_entries:
|
||||||
if "status" in log_entry.changes:
|
if 'status' in LogEntry.changes_dict:
|
||||||
record.last_status_update = log_entry.timestamp.date()
|
record.last_status_update = log_entry.timestamp.date()
|
||||||
break
|
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()
|
|
||||||
|
|
||||||
except ObjectDoesNotExist as e:
|
# Loop through logs in ascending order to find first submission
|
||||||
logger.error(f"Object with object_pk {record.pk} does not exist: {e}")
|
for log_entry in audit_log_entries.reverse():
|
||||||
except Exception as e:
|
if log_entry.changes_dict['status'](1) == 'Submitted':
|
||||||
logger.error(f"An error occurred during update_record: {e}")
|
record.first_submitted_date = log_entry.timestamp.date()
|
||||||
|
break
|
||||||
|
|
||||||
logger.info(
|
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()
|
||||||
|
|
|
@ -35,7 +35,7 @@ class Migration(migrations.Migration):
|
||||||
field=models.DateField(
|
field=models.DateField(
|
||||||
blank=True,
|
blank=True,
|
||||||
default=None,
|
default=None,
|
||||||
help_text="Date of last status updated",
|
help_text="Date of the last status update",
|
||||||
null=True,
|
null=True,
|
||||||
verbose_name="last updated on",
|
verbose_name="last updated on",
|
||||||
),
|
),
|
||||||
|
|
|
@ -563,7 +563,7 @@ class DomainRequest(TimeStampedModel):
|
||||||
help_text="Acknowledged .gov acceptable use policy",
|
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(
|
first_submitted_date = models.DateField(
|
||||||
null=True,
|
null=True,
|
||||||
blank=True,
|
blank=True,
|
||||||
|
@ -572,7 +572,7 @@ class DomainRequest(TimeStampedModel):
|
||||||
help_text="Date initially submitted",
|
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(
|
last_submitted_date = models.DateField(
|
||||||
null=True,
|
null=True,
|
||||||
blank=True,
|
blank=True,
|
||||||
|
@ -581,13 +581,13 @@ class DomainRequest(TimeStampedModel):
|
||||||
help_text="Date last submitted",
|
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(
|
last_status_update = models.DateField(
|
||||||
null=True,
|
null=True,
|
||||||
blank=True,
|
blank=True,
|
||||||
default=None,
|
default=None,
|
||||||
verbose_name="last updated on",
|
verbose_name="last updated on",
|
||||||
help_text="Date of last status updated",
|
help_text="Date of the last status update",
|
||||||
)
|
)
|
||||||
notes = models.TextField(
|
notes = models.TextField(
|
||||||
null=True,
|
null=True,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue