snapshot: preserve role-aware notification preferences and operational alerts

This commit is contained in:
Md Bayazid Bostame
2026-03-27 11:26:57 +01:00
parent fe3a8933fd
commit aa54f41731
25 changed files with 2958 additions and 633 deletions

View File

@@ -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