mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-17 01:57:03 +02:00
cleanup
This commit is contained in:
parent
0a58ea39a9
commit
86ef6e24c3
1 changed files with 54 additions and 50 deletions
|
@ -1827,15 +1827,34 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
|
|
||||||
# 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)
|
||||||
|
if entry:
|
||||||
|
filtered_entries.append(entry)
|
||||||
|
|
||||||
|
except ObjectDoesNotExist as e:
|
||||||
|
logger.error(f"Object with object_id {object_id} does not exist: {e}")
|
||||||
|
except Exception as 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
|
||||||
|
extra_context = extra_context or {}
|
||||||
|
extra_context["filtered_entries"] = filtered_entries
|
||||||
|
|
||||||
|
# Call the superclass method with updated extra_context
|
||||||
|
return super().change_view(request, object_id, form_url, extra_context)
|
||||||
|
|
||||||
|
def process_log_entry(self, log_entry):
|
||||||
|
"""Process a log entry and return filtered entry dictionary if applicable."""
|
||||||
changes = log_entry.changes
|
changes = log_entry.changes
|
||||||
status_changed = "status" in changes
|
status_changed = "status" in changes
|
||||||
rejection_reason_changed = "rejection_reason" in changes
|
rejection_reason_changed = "rejection_reason" in changes
|
||||||
action_needed_reason_changed = "action_needed_reason" in changes
|
action_needed_reason_changed = "action_needed_reason" in changes
|
||||||
|
|
||||||
# Check if the log entry meets the filtering criteria
|
# Check if the log entry meets the filtering criteria
|
||||||
if status_changed or (
|
if status_changed or (not status_changed and (rejection_reason_changed or action_needed_reason_changed)):
|
||||||
not status_changed and (rejection_reason_changed or action_needed_reason_changed)
|
|
||||||
):
|
|
||||||
entry = {}
|
entry = {}
|
||||||
|
|
||||||
# Handle status change
|
# Handle status change
|
||||||
|
@ -1874,24 +1893,9 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
entry["actor"] = log_entry.actor
|
entry["actor"] = log_entry.actor
|
||||||
entry["timestamp"] = log_entry.timestamp
|
entry["timestamp"] = log_entry.timestamp
|
||||||
|
|
||||||
# Append the filtered entry to the list
|
return entry
|
||||||
filtered_entries.append(entry)
|
|
||||||
|
|
||||||
except ObjectDoesNotExist as e:
|
return None
|
||||||
logger.error(f"Object with object_id {object_id} does not exist: {e}")
|
|
||||||
except Exception as 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
|
|
||||||
if extra_context is None:
|
|
||||||
extra_context = {}
|
|
||||||
extra_context["filtered_entries"] = filtered_entries
|
|
||||||
|
|
||||||
# Call the superclass method with updated extra_context
|
|
||||||
return super().change_view(request, object_id, form_url, extra_context)
|
|
||||||
|
|
||||||
|
|
||||||
class TransitionDomainAdmin(ListHeaderAdmin):
|
class TransitionDomainAdmin(ListHeaderAdmin):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue