Files
ping-mee-self-service-platform/portal/shell/views.py
T
ebbe.bassandClaude Sonnet 5.5 0dc079a8ac feat: add page shell, preferences and translations
Base layout with top bar, role-based menu, profile menu and phone layout; theme, language and German form of address kept in cookies; German formal, German informal and English text; Fluent avatar bundled in the image by a Node build stage; placeholder pages for the Publisher and Admin groups.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N3t4WL7bd9bdHHNjEsxzqC
2026-10-17 21:05:40 +02:00

38 lines
1.3 KiB
Python

from django.conf import settings
from django.http import HttpResponseRedirect
from django.shortcuts import render
from django.utils.http import url_has_allowed_host_and_scheme
from django.utils.translation import gettext_lazy as _
from django.views.decorators.http import require_POST
from portal.accounts.decorators import admin_required, publisher_required
from . import preferences
@require_POST
def set_preferences(request):
"""Store the chosen preferences in cookies (the no-JavaScript path of the profile menu)."""
target = request.POST.get("next", "")
if not (target.startswith("/") and url_has_allowed_host_and_scheme(target, None)):
target = "/"
response = HttpResponseRedirect(target)
preferences.set_cookies(
response, preferences.chosen(request.POST), secure=not settings.DEBUG
)
return response
def _placeholder(title):
def view(request):
return render(request, "shell/placeholder.html", {"title": title})
return view
publish_announcements = publisher_required(_placeholder(_("Manage announcements")))
admin_appearance = admin_required(_placeholder(_("Appearance")))
admin_settings = admin_required(_placeholder(_("Settings")))
admin_audit = admin_required(_placeholder(_("Audit log")))
admin_status = admin_required(_placeholder(_("Status")))