mirror of
https://github.com/jazzband/django-auditlog.git
synced 2026-03-16 22:20:26 +00:00
Compare commits
6 commits
5e202c86e7
...
d9bb3ee1d7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d9bb3ee1d7 | ||
|
|
0e3a2ec1a7 | ||
|
|
dfd5b79d2d | ||
|
|
01ac6ec94d | ||
|
|
bbc358db06 | ||
|
|
c43d10a83e |
2 changed files with 17 additions and 7 deletions
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
repos:
|
||||
- repo: https://github.com/psf/black-pre-commit-mirror
|
||||
rev: 26.1.0
|
||||
rev: 26.3.0
|
||||
hooks:
|
||||
- id: black
|
||||
language_version: python3.10
|
||||
|
|
@ -14,7 +14,7 @@ repos:
|
|||
- id: flake8
|
||||
args: ["--max-line-length", "110"]
|
||||
- repo: https://github.com/PyCQA/isort
|
||||
rev: 8.0.0
|
||||
rev: 8.0.1
|
||||
hooks:
|
||||
- id: isort
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
|
|
@ -23,7 +23,7 @@ repos:
|
|||
- id: pyupgrade
|
||||
args: [--py310-plus]
|
||||
- repo: https://github.com/adamchainz/django-upgrade
|
||||
rev: 1.29.1
|
||||
rev: 1.30.0
|
||||
hooks:
|
||||
- id: django-upgrade
|
||||
args: [--target-version, "4.2"]
|
||||
|
|
|
|||
|
|
@ -10,6 +10,14 @@ from auditlog.mixins import LogEntryAdminMixin
|
|||
|
||||
LogEntry = get_logentry_model()
|
||||
|
||||
user_model = get_user_model()
|
||||
|
||||
user_model_fields = [field.name for field in user_model._meta.get_fields()]
|
||||
|
||||
has_first_and_last_name_fields = (
|
||||
"first_name" in user_model_fields and "last_name" in user_model_fields
|
||||
)
|
||||
|
||||
|
||||
@admin.register(LogEntry)
|
||||
class LogEntryAdmin(admin.ModelAdmin, LogEntryAdminMixin):
|
||||
|
|
@ -27,10 +35,12 @@ class LogEntryAdmin(admin.ModelAdmin, LogEntryAdminMixin):
|
|||
"timestamp",
|
||||
"object_repr",
|
||||
"changes",
|
||||
"actor__first_name",
|
||||
"actor__last_name",
|
||||
f"actor__{get_user_model().USERNAME_FIELD}",
|
||||
]
|
||||
f"actor__{user_model.USERNAME_FIELD}",
|
||||
] + (
|
||||
["actor__first_name", "actor__last_name"]
|
||||
if has_first_and_last_name_fields
|
||||
else []
|
||||
)
|
||||
list_filter = ["action", ResourceTypeFilter, CIDFilter]
|
||||
readonly_fields = ["created", "resource_url", "action", "user_url", "msg"]
|
||||
fieldsets = [
|
||||
|
|
|
|||
Loading…
Reference in a new issue