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
4# from django.utils.translation import gettext_lazy as _
5from .models import Category, Notification, NotificationUser
7# Exports
9__all__ = (
10 "CategoryAdmin",
11 "NotificationAdmin",
12 "NotificationUserAdmin",
13)
16# Models
19@admin.register(Category)
20class CategoryAdmin(admin.ModelAdmin):
21 """Django admin for notification categories."""
23 fields = [
24 "label",
25 "value",
26 "abbr",
27 "description",
28 "is_enabled",
29 ]
30 prepopulated_fields = {
31 'value': ("label",),
32 }
34 list_display = [
35 "label",
36 "value",
37 "abbr",
38 "is_enabled",
39 ]
41 list_filter = [
42 "is_enabled",
43 ]
46@admin.register(Notification)
47class NotificationAdmin(admin.ModelAdmin):
48 """Django admin for notifications."""
49 fields = [
50 "subject",
51 "category",
52 "body",
53 "body_sms",
54 "level",
55 "icon_override",
56 "users",
57 "is_mandatory",
58 "is_promoted",
59 "html_enabled",
60 "email_enabled",
61 "sms_enabled",
62 "action_url",
63 "action_text",
64 ]
66 list_display = [
67 "subject",
68 "category",
69 "level",
70 "is_mandatory",
71 "is_promoted",
72 ]
74 list_filter = [
75 "category",
76 "level",
77 "is_mandatory",
78 "is_promoted",
79 ]
82@admin.register(NotificationUser)
83class NotificationUserAdmin(admin.ModelAdmin):
84 """Django admin for user notifications log."""
86 fields = [
87 "notification",
88 "user",
89 "has_been_viewed",
90 "viewed_dt",
91 "sent_email",
92 "sent_sms",
93 ]
94 readonly_fields = [
95 "notification",
96 "user",
97 "has_been_viewed",
98 "viewed_dt",
99 "sent_email",
100 "sent_sms",
101 ]
103 list_display = [
104 "notification",
105 "user",
106 "has_been_viewed",
107 "viewed_dt",
108 "sent_email",
109 "sent_sms",
110 ]
111 list_filter = [
112 "has_been_viewed",
113 "user",
114 "sent_email",
115 "sent_sms"
116 ]