Skip to content

Commit

Permalink
Adds admin interface for user notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
djperrefort committed Aug 6, 2024
1 parent 3c0e3df commit 4b4704f
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions keystone_api/apps/notifications/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""Extends the builtin Django admin interface for the parent application.
Extends and customizes the site-wide administration utility with
interfaces for managing application database constructs.
"""

from django.contrib import admin

from .models import *

settings.JAZZMIN_SETTINGS['icons'].update({
'notifications.Notification': 'fa fa-envelope',
'notifications.Preference': 'fas fa-mail-bulk',
})

settings.JAZZMIN_SETTINGS['order_with_respect_to'].extend([
'notifications.Preference',
'notifications.Notification',
])


@admin.register(Notification)
class NotificationAdmin(admin.ModelAdmin):
"""Admin interface for user notifications"""

list_display = ('user', 'notification_type', 'time', 'read')
list_filter = ('read', 'notification_type', 'time')
search_fields = ('user__username', 'message')

def has_change_permission(self, request, obj=None) -> False:
return False

def has_add_permission(self, request, obj=None) -> False:
return False

def has_delete_permission(self, request, obj=None) -> False:
return False


@admin.register(Preference)
class PreferenceAdmin(admin.ModelAdmin):
"""Admin interface for user notification preferences"""

list_display = ('user',)
search_fields = ('user__username',)

0 comments on commit 4b4704f

Please sign in to comment.