Add custom django CustomNotificationAdmin
This commit is contained in:
parent
d8bce90b8e
commit
b26ec64edb
|
|
@ -120,11 +120,10 @@ RUN chown django:django ${APP_HOME}
|
|||
|
||||
USER django
|
||||
|
||||
# pip install under the user django, the scripts will be in /home/django/.local/bin
|
||||
RUN pip install supervisor
|
||||
RUN exit
|
||||
COPY ./compose/django/supervisord.conf /app/supervisord.conf
|
||||
|
||||
EXPOSE 7555
|
||||
|
||||
COPY ./compose/django/supervisord.conf /app/supervisord.conf
|
||||
|
||||
ENTRYPOINT ["/entrypoint"]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
from vbv_lernwelt.core.admin import LogAdmin
|
||||
|
||||
|
||||
# admin.register in apps.py
|
||||
class CustomNotificationAdmin(LogAdmin):
|
||||
date_hierarchy = "timestamp"
|
||||
raw_id_fields = ("recipient",)
|
||||
list_display = (
|
||||
"recipient",
|
||||
"actor",
|
||||
"notification_type",
|
||||
"emailed",
|
||||
"unread",
|
||||
)
|
||||
list_filter = (
|
||||
"notification_type",
|
||||
"emailed",
|
||||
"unread",
|
||||
"timestamp",
|
||||
"level",
|
||||
"public",
|
||||
)
|
||||
|
||||
def get_queryset(self, request):
|
||||
qs = super(CustomNotificationAdmin, self).get_queryset(request)
|
||||
return qs.prefetch_related("actor")
|
||||
|
|
@ -1,6 +1,20 @@
|
|||
from django.apps import AppConfig
|
||||
from django.contrib import admin
|
||||
|
||||
|
||||
class NotifyConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "vbv_lernwelt.notify"
|
||||
|
||||
def ready(self):
|
||||
# Move the admin import here to avoid early imports
|
||||
from .admin import CustomNotificationAdmin
|
||||
|
||||
# Unregister the default Notification admin if it exists
|
||||
from vbv_lernwelt.notify.models import Notification
|
||||
|
||||
if admin.site.is_registered(Notification):
|
||||
admin.site.unregister(Notification)
|
||||
|
||||
# Register the custom admin
|
||||
admin.site.register(Notification, CustomNotificationAdmin)
|
||||
|
|
|
|||
|
|
@ -125,7 +125,8 @@ class TestNotificationService(TestCase):
|
|||
self.assertEqual(target_url, notification.target_url)
|
||||
self.assertEqual(course, notification.course)
|
||||
self.assertEqual(
|
||||
str(NotificationType.USER_INTERACTION), notification.notification_type
|
||||
str(NotificationType.USER_INTERACTION),
|
||||
notification.notification_type,
|
||||
)
|
||||
self.assertTrue(notification.emailed)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue