Skip to content

Commit

Permalink
✨ [#16] added content_type in list_display
Browse files Browse the repository at this point in the history
We don't rely on the __str__ method of content_type as it also
displays the app label, which is not interesting for our audit logs.
  • Loading branch information
bart-maykin authored and sergei-maertens committed Oct 23, 2024
1 parent 2d39e95 commit d505192
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/woo_publications/logging/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.contrib import admin
from django.contrib.admin import SimpleListFilter
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.http import HttpRequest
from django.urls import NoReverseMatch, reverse
Expand Down Expand Up @@ -35,6 +36,7 @@ class TimelineLogProxyAdmin(admin.ModelAdmin):
list_display = (
"message",
"show_event",
"show_content_type",
"timestamp",
"show_acting_user",
"content_admin_link",
Expand Down Expand Up @@ -80,6 +82,13 @@ def show_event(self, obj: TimelineLogProxy) -> str:
return gettext("Unknown")
return Events(event).label

@admin.display(description=_("kind"), ordering="content_type")
def show_content_type(self, obj: TimelineLogProxy) -> str | None:
ct: ContentType | None = obj.content_type
if ct is None:
return None
return ct.name

@admin.display(description=_("acting user"))
def show_acting_user(self, obj: TimelineLogProxy) -> str:
acting_user, django_user = obj.acting_user
Expand Down

0 comments on commit d505192

Please sign in to comment.