View erstellen
This commit is contained in:
@@ -6,4 +6,5 @@ app_name = 'play'
|
||||
urlpatterns = [
|
||||
path('lobby/<str:join_code>', views.lobby, name='lobby'),
|
||||
path('join', views.join_game, name='join_game'),
|
||||
path('participant', views.create_participant, name='create_participant'),
|
||||
]
|
||||
@@ -2,12 +2,22 @@ from django.shortcuts import render
|
||||
from django.shortcuts import render, redirect, get_object_or_404
|
||||
from play.models import QuizGame
|
||||
from library.models import QivipQuiz
|
||||
from django.http import HttpResponse
|
||||
|
||||
# Create your views here.
|
||||
def lobby(request, join_code):
|
||||
quiz_game = get_object_or_404(QuizGame, join_code=join_code)
|
||||
return render(request, 'play/lobby.html', {'debug': "test"})
|
||||
|
||||
def create_participant(request):
|
||||
join_code = request.GET.get('join_code')
|
||||
if "participant_id" in request.COOKIES:
|
||||
return redirect('play:lobby', join_code=join_code)
|
||||
if request.method == 'POST':
|
||||
display_name = request.POST.get('username')
|
||||
join_code = request.POST.get('join_code')
|
||||
return render('play/initialize_participant.html', {'join_code': join_code})
|
||||
|
||||
def join_game(request):
|
||||
if request.method == 'POST':
|
||||
join_code = request.POST.get('game_code')
|
||||
|
||||
Reference in New Issue
Block a user