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)

View File

@@ -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 }}">
<p class="text-xs text-gray-500 mt-2">Maximal 20 Zeichen</p>
</div>

View File

@@ -20,6 +20,7 @@
<span class="w-2 h-2 bg-green-500 rounded-full mr-2"></span>
<span>Angemeldet als <b>{{ participant.display_name }}</b></span>
</div>
<a href="{% url 'play:create_participant' quiz_game.join_code %}">Auftreten ändern...</a>
</div>
{% endif %}