fixed redirection in events

This commit is contained in:
Danhia 2022-02-04 19:04:17 +01:00
parent 6c0cc7d5c8
commit 96121e401e
2 changed files with 7 additions and 9 deletions

View File

@ -86,15 +86,11 @@ def event(request, event_slug):
player = None
if player:
IsRegistered = True
if not player.team and event_info.team_size > 1:
return render(request, 'events/create_team.html', {'event' : event_info, 'logged': True, 'wrongpwd': False, 'registered' : True, 'notexist' : False})
if event_info.password:
if request.user.is_authenticated:
if request.user.is_staff is False:
if not player:
return render(request, 'events/event_pwd.html', {'event' : event_info, 'logged': True, 'wrongpwd': wrongpwd, 'alreadyregistered': alreadyregistered})
elif not player.team and event_info.team_size > 1:
return render(request, 'events/create_team.html', {'event' : event_info, 'logged': True, 'wrongpwd': False, 'registered' : True, 'notexist' : False})
else:
return render(request, 'events/event_pwd.html', {'event' : event_info, 'logged': False, 'wrongpwd': wrongpwd, 'alreadyregistered': alreadyregistered})
ended = False
@ -191,8 +187,8 @@ def submit_pwd(request, event_slug):
else:
new = EventPlayer(user=request.user, event=ev)
new.save()
if event_info.team_size > 1:
return render(request, 'events/create_team.html', {'event' : event_info, 'logged': True, 'wrongpwd': False, 'registered' : True, 'notexist' : False})
# if event_info.team_size > 1:
# return render(request, 'events/create_team.html', {'event' : event_info, 'logged': True, 'wrongpwd': False, 'registered' : True, 'notexist' : False})
return redirect('events:event_info', event_slug=event_slug)

View File

@ -11,7 +11,6 @@ from random import randint
@login_required
def create_team(request, event_slug):
response = redirect('events:create_team', event_slug=event_slug)
ev = get_object_or_404(Event, slug=event_slug)
if request.method == 'POST':
if request.user.is_authenticated and ev.team_size > 1:
@ -23,10 +22,11 @@ def create_team(request, event_slug):
player.team = new
player.save()
return redirect('events:event_info', event_slug=event_slug)
else:
return render(request, 'events/create_team.html', {'event' : ev, 'logged': True, 'wrongpwd': False, 'registered' : True, 'exist' : False})
@login_required
def join_team(request, event_slug):
response = redirect('events:join_team', event_slug=event_slug)
ev = get_object_or_404(Event, slug=event_slug)
if request.method == 'POST':
if request.user.is_authenticated and ev.team_size > 1:
@ -102,6 +102,8 @@ def team_info(request, name, event_slug):
def manage_team(request, event_slug):
event_info = get_object_or_404(Event, slug=event_slug)
player = EventPlayer.objects.get(user=request.user, event=event_info)
if not player.team:
return render(request, 'events/create_team.html', {'event' : event_info, 'logged': True, 'wrongpwd': False, 'registered' : True, 'notexist' : False})
members = EventPlayer.objects.filter(team=player.team, event=event_info)
if request.method == 'POST':