mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-17 18:09:25 +02:00
revisions
This commit is contained in:
parent
86ef6e24c3
commit
5a8329855c
2 changed files with 10 additions and 13 deletions
|
@ -1819,29 +1819,26 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
self.display_restricted_warning(request, obj)
|
self.display_restricted_warning(request, obj)
|
||||||
|
|
||||||
# Initialize variables for tracking status changes and filtered entries
|
# Initialize variables for tracking status changes and filtered entries
|
||||||
filtered_entries = []
|
filtered_audit_log_entries = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Retrieve and order audit log entries by timestamp in ascending order
|
# Retrieve and order audit log entries by timestamp in descending order
|
||||||
audit_log_entries = LogEntry.objects.filter(object_id=object_id).order_by("timestamp")
|
audit_log_entries = LogEntry.objects.filter(object_id=object_id).order_by("-timestamp")
|
||||||
|
|
||||||
# Process each log entry to filter based on the change criteria
|
# Process each log entry to filter based on the change criteria
|
||||||
for log_entry in audit_log_entries:
|
for log_entry in audit_log_entries:
|
||||||
entry = self.process_log_entry(log_entry)
|
entry = self.process_log_entry(log_entry)
|
||||||
if entry:
|
if entry:
|
||||||
filtered_entries.append(entry)
|
filtered_audit_log_entries.append(entry)
|
||||||
|
|
||||||
except ObjectDoesNotExist as e:
|
except ObjectDoesNotExist as e:
|
||||||
logger.error(f"Object with object_id {object_id} does not exist: {e}")
|
logger.error(f"Object with object_id {object_id} does not exist: {e}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"An error occurred during change_view: {e}")
|
logger.error(f"An error occurred during change_view: {e}")
|
||||||
|
|
||||||
# Reverse the filtered entries list to get newest to oldest order
|
|
||||||
filtered_entries.reverse()
|
|
||||||
|
|
||||||
# Initialize extra_context and add filtered entries
|
# Initialize extra_context and add filtered entries
|
||||||
extra_context = extra_context or {}
|
extra_context = extra_context or {}
|
||||||
extra_context["filtered_entries"] = filtered_entries
|
extra_context["filtered_audit_log_entries"] = filtered_audit_log_entries
|
||||||
|
|
||||||
# Call the superclass method with updated extra_context
|
# Call the superclass method with updated extra_context
|
||||||
return super().change_view(request, object_id, form_url, extra_context)
|
return super().change_view(request, object_id, form_url, extra_context)
|
||||||
|
@ -1859,13 +1856,13 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
|
|
||||||
# Handle status change
|
# Handle status change
|
||||||
if status_changed:
|
if status_changed:
|
||||||
status_value = changes.get("status", [None, None])[1]
|
_, status_value = changes.get("status")
|
||||||
if status_value:
|
if status_value:
|
||||||
entry["status"] = DomainRequest.DomainRequestStatus(status_value).label
|
entry["status"] = DomainRequest.DomainRequestStatus(status_value).label
|
||||||
|
|
||||||
# Handle rejection reason change
|
# Handle rejection reason change
|
||||||
if rejection_reason_changed:
|
if rejection_reason_changed:
|
||||||
rejection_reason_value = changes.get("rejection_reason", [None, None])[1]
|
_, rejection_reason_value = changes.get("rejection_reason")
|
||||||
if rejection_reason_value:
|
if rejection_reason_value:
|
||||||
entry["rejection_reason"] = (
|
entry["rejection_reason"] = (
|
||||||
""
|
""
|
||||||
|
@ -1878,7 +1875,7 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
|
|
||||||
# Handle action needed reason change
|
# Handle action needed reason change
|
||||||
if action_needed_reason_changed:
|
if action_needed_reason_changed:
|
||||||
action_needed_reason_value = changes.get("action_needed_reason", [None, None])[1]
|
_, action_needed_reason_value = changes.get("action_needed_reason")
|
||||||
if action_needed_reason_value:
|
if action_needed_reason_value:
|
||||||
entry["action_needed_reason"] = (
|
entry["action_needed_reason"] = (
|
||||||
""
|
""
|
||||||
|
|
|
@ -68,7 +68,7 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
|
||||||
{% endblock field_readonly %}
|
{% endblock field_readonly %}
|
||||||
|
|
||||||
{% block after_help_text %}
|
{% block after_help_text %}
|
||||||
{% if field.field.name == "status" and filtered_entries %}
|
{% if field.field.name == "status" and filtered_audit_log_entries %}
|
||||||
<div class="flex-container" id="dja-status-changelog">
|
<div class="flex-container" id="dja-status-changelog">
|
||||||
<label aria-label="Status changelog"></label>
|
<label aria-label="Status changelog"></label>
|
||||||
<div>
|
<div>
|
||||||
|
@ -82,7 +82,7 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for entry in filtered_entries %}
|
{% for entry in filtered_audit_log_entries %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
{% if entry.status %}
|
{% if entry.status %}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue