37 lines
1.0 KiB
Python
37 lines
1.0 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
|
|
|
|
|
|
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 settings.WPP_SPA_ENABLED:
|
|
host_route = "/host"
|
|
if spa_path:
|
|
host_route = f"/host/{spa_path.strip('/')}"
|
|
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 settings.WPP_SPA_ENABLED:
|
|
return _render_spa_shell(request, "/player", "player")
|
|
|
|
return render(request, "lobby/player_screen.html")
|