Skip to content

Commit

Permalink
Adds admin interface for user notifications (#357)
Browse files Browse the repository at this point in the history
* Adds admin interface for user notifications

* Enable delete permissions

* pep8
  • Loading branch information
djperrefort authored Aug 6, 2024
1 parent c7e75bd commit c1e4cd4
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions keystone_api/apps/notifications/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""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


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

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

0 comments on commit c1e4cd4

Please sign in to comment.