feat: Add AdminAuditLog model with read-only admin view#388
Open
mayasimi wants to merge 2 commits intoSoroScan:mainfrom
Open
feat: Add AdminAuditLog model with read-only admin view#388mayasimi wants to merge 2 commits intoSoroScan:mainfrom
mayasimi wants to merge 2 commits intoSoroScan:mainfrom
Conversation
… coverage - Add AdminAuditLog model (immutable, append-only) tracking create/update/delete actions with user, action type, object repr, content_type, object_id, IP, timestamp - Add migration 0037_adminauditlog with composite indexes - Update AdminAuditMixin._audit() to write to both AdminAction and AdminAuditLog - Register AdminAuditLogAdmin as read-only view with colored action display, date_hierarchy, search, and list filters - Add AdminAuditLogFactory to test factories - Add 28 tests covering model immutability, mixin logging (add/change/delete), IP extraction (direct + X-Forwarded-For), anonymous user handling, admin permissions, and colored display - Update test_migration_graph.py leaf node assertion to 0037_adminauditlog
Contributor
|
@mayasimi Please resolve conflicts |
|
@mayasimi Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Author
|
@DokaIzk Resolved |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
close #360
Summary
Adds a dedicated AdminAuditLog model to track every create, update, and delete action performed through the Django Admin interface, with a read-only view to inspect the audit trail.
What changed
New AdminAuditLog model — immutable, append-only, stores user, action type, affected object, IP address, and timestamp. Attempts to update or delete a record raise ValidationError.
Updated AdminAuditMixin._audit() to write to AdminAuditLog on every admin add/change/delete, in addition to the existing AdminAction log.
AdminAuditLogAdmin registered as a fully read-only view with color-coded action display, date hierarchy, search, and filters.
Migration 0037_adminauditlog with composite indexes on (action, timestamp), (content_type, object_id), and (user, timestamp).
Tests
28 new tests covering:
Model immutability (no updates, no deletes)
Mixin logs create, update, and delete correctly
IP extraction from REMOTE_ADDR and X-Forwarded-For
Anonymous user stored as null
Admin view has no add/change/delete permissions
All fields are read-only
Color-coded action display
Result: 463 passed, 5 skipped (pre-existing hypothesis env issue, unrelated)
Acceptance criteria met
AdminAuditLog model created
All admin changes logged (create, update, delete)
Includes user, action, and timestamp
Audit log viewable in admin (read-only)
Tests verify audit logging