snapshot: preserve role-aware notification preferences and operational alerts
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from .branding import get_branding_context, get_trial_context
|
||||
from .models import UserNotification
|
||||
from .roles import template_role_context
|
||||
|
||||
|
||||
@@ -6,4 +7,15 @@ def role_context(request):
|
||||
context = template_role_context(getattr(request, 'user', None))
|
||||
context.update(get_branding_context())
|
||||
context.update(get_trial_context())
|
||||
user = getattr(request, 'user', None)
|
||||
if getattr(user, 'is_authenticated', False):
|
||||
notifications = list(UserNotification.objects.filter(user=user).order_by('-created_at')[:8])
|
||||
context.update(
|
||||
{
|
||||
'header_notifications': notifications,
|
||||
'header_unread_notification_count': UserNotification.objects.filter(user=user, read_at__isnull=True).count(),
|
||||
}
|
||||
)
|
||||
else:
|
||||
context.update({'header_notifications': [], 'header_unread_notification_count': 0})
|
||||
return context
|
||||
|
||||
Reference in New Issue
Block a user