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
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
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")))
|
||||
Reference in New Issue
Block a user