feat: switch to spa

This commit is contained in:
2026-09-17 00:56:17 +02:00
parent 15590e5162
commit d104480188
23 changed files with 327 additions and 171 deletions
+32
View File
@@ -31,6 +31,38 @@ def list_my_scopes(request: HttpRequest, event_path: str, game_path: str):
)
@router.get(f"{PREFIX}/{{game_path}}/available-scopes", response={200: list[ScopeOut], 403: dict})
def list_available_scopes(request: HttpRequest, event_path: str, game_path: str):
"""Scopes the current user may submit to for this game - superusers see
every active scope, everyone else only the ones assigned to them. Used
by the submissions-select and submissions-detail pages, both to list
scopes and (for the detail page) to confirm the requested scope_id is
one the current user is actually allowed to see."""
if not request.user.is_authenticated:
return 403, {"detail": "Authentication required"}
game = get_object_or_404(
Game.objects.enabled_for_event(request.event), path=game_path
)
scopes = (
Scope.objects.filter(
event_game__event=request.event,
event_game__game=game,
is_active=True,
)
if request.user.is_superuser
else Scope.objects.filter(
event_game__event=request.event,
event_game__game=game,
assigned_users=request.user,
is_active=True,
)
)
return list(scopes.order_by("name"))
@router.post(f"{PREFIX}/submission/create", response={200: SubmissionOut, 403: dict})
def create_submission(
request: HttpRequest,
+2 -27
View File
@@ -39,19 +39,7 @@ def submission_home(request: HttpRequest, event_path: str, game_path: str):
if not scopes:
raise Http404
return render(
request,
"app.html",
{
"bootstrap": {
"gameName": game.name,
"scopes": [
{"id": str(scope.id), "name": scope.name}
for scope in scopes.order_by("name")
],
},
},
)
return render(request, "app.html")
@login_required
@@ -74,17 +62,4 @@ def submission_view(
):
raise Http404
game = scope.event_game.game
return render(
request,
"app.html",
{
"bootstrap": {
"scopeName": scope.name,
"gameName": game.name,
"gamePath": game.path,
"gameImage": game.image or "",
"gameSteamId": str(game.steam_app_id or ""),
},
},
)
return render(request, "app.html")