diff --git a/django/play/views.py b/django/play/views.py index 6887cc0..87871b0 100644 --- a/django/play/views.py +++ b/django/play/views.py @@ -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) diff --git a/django/templates/play/initialize_participant.html b/django/templates/play/initialize_participant.html index 9e92f51..082aaf6 100644 --- a/django/templates/play/initialize_participant.html +++ b/django/templates/play/initialize_participant.html @@ -24,7 +24,8 @@ required maxlength="20" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" - placeholder="Dein Spielername"> + placeholder="Dein Spielername" + value="{{ participant.display_name }}">
Maximal 20 Zeichen
diff --git a/django/templates/play/lobby.html b/django/templates/play/lobby.html index 1731e6b..2da2b91 100644 --- a/django/templates/play/lobby.html +++ b/django/templates/play/lobby.html @@ -20,6 +20,7 @@ Angemeldet als {{ participant.display_name }} + Auftreten ändern... {% endif %}