Disallow changing or deleting log entries (#449)

This commit is contained in:
Alieh Rymašeŭski 2022-11-21 15:26:23 +00:00 committed by GitHub
parent 96275d5386
commit 1ba3bd9d07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

View file

@ -1,5 +1,8 @@
# Changes
#### Fixes
- fix: Make log entries read-only in the admin. ([#449](https://github.com/jazzband/django-auditlog/pull/449))
## 2.2.0 (2022-10-07)
#### Improvements

View file

@ -26,5 +26,10 @@ class LogEntryAdmin(admin.ModelAdmin, LogEntryAdminMixin):
]
def has_add_permission(self, request):
# As audit admin doesn't allow log creation from admin
return False
def has_change_permission(self, request, obj=None):
return False
def has_delete_permission(self, request, obj=None):
return False

View file

@ -1292,7 +1292,7 @@ class AdminPanelTest(TestCase):
res = self.client.get(f"/admin/auditlog/logentry/{log_pk}/", follow=True)
self.assertEqual(res.status_code, 200)
res = self.client.get(f"/admin/auditlog/logentry/{log_pk}/delete/")
self.assertEqual(res.status_code, 200)
self.assertEqual(res.status_code, 403)
res = self.client.get(f"/admin/auditlog/logentry/{log_pk}/history/")
self.assertEqual(res.status_code, 200)