From 1f1344522ff96dac1f55e84026becc454c515744 Mon Sep 17 00:00:00 2001 From: juhnsa Date: Sun, 16 Mar 2025 09:55:36 +0100 Subject: [PATCH 1/2] Quiz Instanz von Teilnehmer updaten, wenn dieser einem anderen Quiz beitritt --- django/play/views.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/django/play/views.py b/django/play/views.py index bc69f69..b701203 100644 --- a/django/play/views.py +++ b/django/play/views.py @@ -8,10 +8,13 @@ from django.http import HttpResponseRedirect def lobby(request, join_code): if not "participant_id" in request.COOKIES: return redirect('play:create_participant', join_code=join_code) - participant_id = request.COOKIES['participant_id'] quiz_game = get_object_or_404(QuizGame, join_code=join_code) participant = get_object_or_404(QuizGameParticipant, participant_id=participant_id) + + if not participant.quiz_game.join_code == join_code: + participant.quiz_game = quiz_game + participant.save() return render(request, 'play/lobby.html', {'debug': "test", 'participant': participant}) def create_participant(request, join_code): From d1cca38595b98a1d1d5f2ec879e5c3f35e0cc4e6 Mon Sep 17 00:00:00 2001 From: juhnsa Date: Sun, 16 Mar 2025 11:54:00 +0100 Subject: [PATCH 2/2] Quiz Titel anzeigen --- django/play/views.py | 10 +++++++++- django/templates/play/lobby.html | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/django/play/views.py b/django/play/views.py index b701203..23f0abb 100644 --- a/django/play/views.py +++ b/django/play/views.py @@ -10,12 +10,20 @@ def lobby(request, join_code): return redirect('play:create_participant', join_code=join_code) participant_id = request.COOKIES['participant_id'] quiz_game = get_object_or_404(QuizGame, join_code=join_code) + quiz = get_object_or_404(QivipQuiz, pk=quiz_game.quiz_id.id) participant = get_object_or_404(QuizGameParticipant, participant_id=participant_id) if not participant.quiz_game.join_code == join_code: participant.quiz_game = quiz_game participant.save() - return render(request, 'play/lobby.html', {'debug': "test", 'participant': participant}) + + context = { + 'debug': "test", + 'participant': participant, + 'quiz': quiz, + } + + return render(request, 'play/lobby.html', context=context) def create_participant(request, join_code): if "participant_id" in request.COOKIES: # Umleiten, falls Teilnehmer bereits erstellt diff --git a/django/templates/play/lobby.html b/django/templates/play/lobby.html index 1bdd7f5..6227d01 100644 --- a/django/templates/play/lobby.html +++ b/django/templates/play/lobby.html @@ -2,7 +2,7 @@ {% block content %}
-

Bundeslaender Deutschland Quiz

+

{{ quiz.name }}

Sichtbar als {{ participant.display_name }}