Source code for superdjango.contrib.notifications.admin

# Imports

from django.contrib import admin
# from django.utils.translation import gettext_lazy as _
from .models import Category, Notification, NotificationUser

# Exports

__all__ = (
    "CategoryAdmin",
    "NotificationAdmin",
    "NotificationUserAdmin",
)


# Models


[docs]@admin.register(Category) class CategoryAdmin(admin.ModelAdmin): """Django admin for notification categories.""" fields = [ "label", "value", "abbr", "description", "is_enabled", ] prepopulated_fields = { 'value': ("label",), } list_display = [ "label", "value", "abbr", "is_enabled", ] list_filter = [ "is_enabled", ]
[docs]@admin.register(Notification) class NotificationAdmin(admin.ModelAdmin): """Django admin for notifications.""" fields = [ "subject", "category", "body", "body_sms", "level", "icon_override", "users", "is_mandatory", "is_promoted", "html_enabled", "email_enabled", "sms_enabled", "action_url", "action_text", ] list_display = [ "subject", "category", "level", "is_mandatory", "is_promoted", ] list_filter = [ "category", "level", "is_mandatory", "is_promoted", ]
[docs]@admin.register(NotificationUser) class NotificationUserAdmin(admin.ModelAdmin): """Django admin for user notifications log.""" fields = [ "notification", "user", "has_been_viewed", "viewed_dt", "sent_email", "sent_sms", ] readonly_fields = [ "notification", "user", "has_been_viewed", "viewed_dt", "sent_email", "sent_sms", ] list_display = [ "notification", "user", "has_been_viewed", "viewed_dt", "sent_email", "sent_sms", ] list_filter = [ "has_been_viewed", "user", "sent_email", "sent_sms" ]