Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# Imports
3from django.contrib import admin
5# Exports
7__all__ = (
8 "BaseHistoryModelAdmin",
9)
12# Models
15class BaseHistoryModelAdmin(admin.ModelAdmin):
16 """Base class for history admin."""
18 def get_fields(self, request, obj=None):
19 return [
20 "added_dt",
21 "content_type",
22 "object_label",
23 "object_id",
24 "user",
25 "user_name",
26 "verb",
27 "verb_display",
28 ]
30 def get_list_display(self, request):
31 return [
32 "object_label",
33 "added_dt",
34 "content_type",
35 "user",
36 "verb",
37 ]
39 def get_list_filter(self, request):
40 return [
41 "content_type",
42 "user",
43 ]
45 def get_readonly_fields(self, request, obj=None):
46 return [
47 "added_dt",
48 "content_type",
49 "object_label",
50 "object_id",
51 "user",
52 "user_name",
53 "verb",
54 "verb_display",
55 ]
57 def has_add_permission(self, request):
58 return False
60 def has_delete_permission(self, request, obj=None):
61 # noinspection PyUnresolvedReferences
62 return self.request.user.is_superuser