-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds admin interface for user notifications (#357)
* Adds admin interface for user notifications * Enable delete permissions * pep8
- Loading branch information
1 parent
c7e75bd
commit c1e4cd4
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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',) |