removed 500 when user is not connected and want to access public event
This commit is contained in:
parent
e4f68edeff
commit
a6095cc5c4
|
@ -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
|
||||||
|
|
|
@ -223,9 +223,9 @@ 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)
|
||||||
if request.method == 'POST':
|
|
||||||
if request.user.is_authenticated:
|
|
||||||
ev = get_object_or_404(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:
|
||||||
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)
|
||||||
|
@ -238,9 +238,9 @@ 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)
|
||||||
if request.method == 'POST':
|
|
||||||
if request.user.is_authenticated:
|
|
||||||
ev = get_object_or_404(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:
|
||||||
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