2024-03-10 19:37:46 +05:30
|
|
|
""" Django notifications admin file """
|
|
|
|
|
|
2023-08-01 16:47:47 +05:30
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
from django.contrib import admin
|
|
|
|
|
from notifications.base.admin import AbstractNotificationAdmin
|
|
|
|
|
from swapper import load_model
|
|
|
|
|
|
2024-03-10 19:37:46 +05:30
|
|
|
Notification = load_model("notifications", "Notification")
|
2023-08-01 16:47:47 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
class NotificationAdmin(AbstractNotificationAdmin):
|
2024-03-10 19:37:46 +05:30
|
|
|
raw_id_fields = ("recipient",)
|
|
|
|
|
list_display = ("recipient", "actor", "level", "target", "unread", "public")
|
|
|
|
|
list_filter = (
|
|
|
|
|
"level",
|
|
|
|
|
"unread",
|
|
|
|
|
"public",
|
|
|
|
|
"timestamp",
|
|
|
|
|
)
|
2023-08-01 16:47:47 +05:30
|
|
|
|
|
|
|
|
def get_queryset(self, request):
|
|
|
|
|
qs = super(NotificationAdmin, self).get_queryset(request)
|
2024-03-10 19:37:46 +05:30
|
|
|
return qs.prefetch_related("actor")
|
2023-08-01 16:47:47 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
admin.site.register(Notification, NotificationAdmin)
|