41 lines
1.2 KiB
Python
41 lines
1.2 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
|
|
|
|
|
|
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,
|
|
},
|
|
)
|
|
|
|
|
|
@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})
|
|
|
|
|
|
def player_screen(request):
|
|
if use_spa_ui():
|
|
return _render_spa_shell(request, "/player", "player")
|
|
|
|
return render(request, "lobby/player_screen.html")
|