removed 500 when user is not connected and want to access public event

This commit is contained in:
Danhia 2022-01-14 23:41:59 +01:00
parent 39d10437f8
commit c360457152
2 changed files with 8 additions and 6 deletions

View File

@ -9,6 +9,8 @@ def isflagged(user, ctf):
flagged = False
event_info = ctf.event
if user.is_authenticated == False:
return ""
if event_info.team_size == 1:
if CTF_flags.objects.filter(user=user, ctf=ctf):
flagged = True

View File

@ -222,10 +222,10 @@ def subscribe_to_event(request, event_slug):
@login_required
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.user.is_authenticated:
ev = get_object_or_404(Event, slug=event_slug)
if request.user.is_authenticated and ev.team_size > 1:
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})
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
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.user.is_authenticated:
ev = get_object_or_404(Event, slug=event_slug)
if request.user.is_authenticated and ev.team_size > 1:
try:
team = Team.objects.get(name=request.POST.get('teamname'), event=ev)
except: