Grundlegende Funktion

This commit is contained in:
juhnsa
2025-04-07 17:19:54 +02:00
parent a89847f818
commit 3df748dc96
3 changed files with 5 additions and 3 deletions

View File

@@ -41,7 +41,7 @@ def lobby(request, join_code):
def create_participant(request, join_code):
quiz_game = get_object_or_404(QuizGame, join_code=join_code)
if "participant_id" in request.COOKIES:
if request.method == 'GET' and "participant_id" in request.COOKIES:
# Prüfe ob der Teilnehmer noch existiert
participant_id = request.COOKIES['participant_id']
try:
@@ -50,7 +50,7 @@ def create_participant(request, join_code):
participant.quiz_game = quiz_game
participant.score = 0 # Reset score when joining new game
participant.save()
return redirect('play:lobby', join_code=join_code)
return render(request, 'play/initialize_participant.html', {'participant': participant, 'join_code': quiz_game.join_code})
except QuizGameParticipant.DoesNotExist:
# Cookie löschen wenn Teilnehmer nicht mehr existiert
response = HttpResponseRedirect(request.path)