Merge branch 'events' into main
This commit is contained in:
commit
206cdd8edb
|
@ -9,6 +9,8 @@ def isflagged(user, ctf):
|
||||||
flagged = False
|
flagged = False
|
||||||
event_info = ctf.event
|
event_info = ctf.event
|
||||||
|
|
||||||
|
if user.is_authenticated == False:
|
||||||
|
return ""
|
||||||
if event_info.team_size == 1:
|
if event_info.team_size == 1:
|
||||||
if CTF_flags.objects.filter(user=user, ctf=ctf):
|
if CTF_flags.objects.filter(user=user, ctf=ctf):
|
||||||
flagged = True
|
flagged = True
|
||||||
|
|
|
@ -222,10 +222,10 @@ def subscribe_to_event(request, event_slug):
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def create_team(request, event_slug):
|
def create_team(request, event_slug):
|
||||||
response = redirect('events:create_team', event_slug=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.method == 'POST':
|
||||||
if request.user.is_authenticated:
|
if request.user.is_authenticated and ev.team_size > 1:
|
||||||
ev = get_object_or_404(Event, slug=event_slug)
|
|
||||||
if Team.objects.filter(name=request.POST.get('teamname'), event=ev).exists():
|
if Team.objects.filter(name=request.POST.get('teamname'), event=ev).exists():
|
||||||
return render(request, 'events/create_team.html', {'event' : ev, 'logged': True, 'wrongpwd': False, 'registered' : True, 'exist' : True})
|
return render(request, 'events/create_team.html', {'event' : ev, 'logged': True, 'wrongpwd': False, 'registered' : True, 'exist' : True})
|
||||||
new = Team(name=request.POST.get('teamname'), password=request.POST.get('password'), event=ev)
|
new = Team(name=request.POST.get('teamname'), password=request.POST.get('password'), event=ev)
|
||||||
|
@ -237,10 +237,10 @@ def create_team(request, event_slug):
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def join_team(request, event_slug):
|
def join_team(request, event_slug):
|
||||||
response = redirect('events:join_team', event_slug=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.method == 'POST':
|
||||||
if request.user.is_authenticated:
|
if request.user.is_authenticated and ev.team_size > 1:
|
||||||
ev = get_object_or_404(Event, slug=event_slug)
|
|
||||||
try:
|
try:
|
||||||
team = Team.objects.get(name=request.POST.get('teamname'), event=ev)
|
team = Team.objects.get(name=request.POST.get('teamname'), event=ev)
|
||||||
except:
|
except:
|
||||||
|
|
Loading…
Reference in New Issue