Files
workdock-platform/backend/workflows/context_processors.py
Md Bayazid Bostame e47b1b3110
Some checks failed
CI / python-validation (push) Has been cancelled
CI / docker-release-gate (push) Has been cancelled
i18n / compile-translations (push) Has been cancelled
feat: add session expiry warning
2026-04-01 22:05:17 +02:00

31 lines
1.2 KiB
Python

from .branding import get_branding_context, get_trial_context
from django.conf import settings
from .models import UserNotification
from .roles import template_role_context
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})
context.update(
{
'static_asset_version': settings.STATIC_ASSET_VERSION,
'session_idle_timeout_seconds': settings.SESSION_IDLE_TIMEOUT_SECONDS,
'session_reauth_timeout_seconds': settings.SENSITIVE_ACTION_REAUTH_SECONDS,
'force_branded_error_pages': settings.FORCE_BRANDED_ERROR_PAGES,
}
)
return context