Files
weirsoe-party-protocol/lobby/ui_views.py
Asger Geel Weirsoee a4c0d0603d
All checks were successful
CI / test-and-quality (push) Successful in 2m55s
CI / test-and-quality (pull_request) Successful in 2m56s
feat(cutover): harden SPA asset cache busting and rollback playbook (#188)
2026-03-01 20:52:04 +00:00

51 lines
1.5 KiB
Python

from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.shortcuts import render
from fupogfakta.models import Category
from .feature_flags import use_spa_ui
from .i18n import lobby_i18n_catalog
def _render_spa_shell(request, shell_route: str, shell_kind: str):
return render(
request,
"lobby/spa_shell.html",
{
"shell_route": shell_route,
"shell_kind": shell_kind,
"spa_asset_base": settings.WPP_SPA_ASSET_BASE,
"spa_asset_version": getattr(settings, "WPP_SPA_ASSET_VERSION", "dev"),
"lobby_i18n": lobby_i18n_catalog(),
},
)
@login_required
def host_screen(request, spa_path=None):
if use_spa_ui():
host_route = "/host"
if spa_path:
normalized_spa_path = "/".join(segment for segment in spa_path.split("/") if segment)
if normalized_spa_path:
host_route = f"/host/{normalized_spa_path}"
return _render_spa_shell(request, host_route, "host")
categories = Category.objects.filter(is_active=True).order_by("name")
return render(
request,
"lobby/host_screen.html",
{
"categories": categories,
"lobby_i18n": lobby_i18n_catalog(),
},
)
def player_screen(request):
if use_spa_ui():
return _render_spa_shell(request, "/player", "player")
return render(request, "lobby/player_screen.html", {"lobby_i18n": lobby_i18n_catalog()})