From 96121e401eb9668d938742e3155d77d3be6fe4f9 Mon Sep 17 00:00:00 2001 From: Danhia Date: Fri, 4 Feb 2022 19:04:17 +0100 Subject: [PATCH] fixed redirection in events --- src/events/views/events.py | 8 ++------ src/events/views/teams.py | 8 +++++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/events/views/events.py b/src/events/views/events.py index 157ae86..8ffdea2 100644 --- a/src/events/views/events.py +++ b/src/events/views/events.py @@ -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) diff --git a/src/events/views/teams.py b/src/events/views/teams.py index af3e2a0..d91cfa8 100644 --- a/src/events/views/teams.py +++ b/src/events/views/teams.py @@ -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: @@ -22,11 +21,12 @@ def create_team(request, event_slug): player = EventPlayer.objects.get(user=request.user, event=ev) player.team = new player.save() - return redirect('events:event_info', event_slug=event_slug) + 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':