Compare commits
No commits in common. "44897411f5b420e5533d6b34737f2f22f887bbc4" and "5a10e033a214896f00c010f59d8d1be606f03d1a" have entirely different histories.
44897411f5
...
5a10e033a2
|
@ -16,9 +16,6 @@
|
||||||
{% if registered == False %}
|
{% if registered == False %}
|
||||||
<span class="message error-msg">{% trans "You need to be registered to the event." %}</span>
|
<span class="message error-msg">{% trans "You need to be registered to the event." %}</span>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if invalid == True %}
|
|
||||||
<span class="message error-msg">{% trans "Invalid characters in name" %}</span>
|
|
||||||
{% endif %}
|
|
||||||
{% if exist == True %}
|
{% if exist == True %}
|
||||||
<span class="message error-msg">{% trans "Name already taken." %}</span>
|
<span class="message error-msg">{% trans "Name already taken." %}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -13,13 +13,10 @@ from random import randint
|
||||||
def create_team(request, event_slug):
|
def create_team(request, event_slug):
|
||||||
ev = get_object_or_404(Event, slug=event_slug)
|
ev = get_object_or_404(Event, slug=event_slug)
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
teamname = request.POST.get('teamname')
|
|
||||||
if request.user.is_authenticated and ev.team_size > 1:
|
if request.user.is_authenticated and ev.team_size > 1:
|
||||||
if any(c in set('./') for c in teamname):
|
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' : False, 'invalid' : True})
|
|
||||||
if Team.objects.filter(name=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=teamname, password=request.POST.get('password'), event=ev)
|
new = Team(name=request.POST.get('teamname'), password=request.POST.get('password'), event=ev)
|
||||||
new.save()
|
new.save()
|
||||||
player = EventPlayer.objects.get(user=request.user, event=ev)
|
player = EventPlayer.objects.get(user=request.user, event=ev)
|
||||||
player.team = new
|
player.team = new
|
||||||
|
@ -118,9 +115,8 @@ def manage_team(request, event_slug):
|
||||||
pname = p_form.cleaned_data['name']
|
pname = p_form.cleaned_data['name']
|
||||||
if pname == tname:
|
if pname == tname:
|
||||||
pass
|
pass
|
||||||
elif any(c in set('./') for c in pname):
|
else:
|
||||||
error = _("Invalid characters in name")
|
if Team.objects.filter(name=pname, event=event_info).exists():
|
||||||
elif Team.objects.filter(name=pname, event=event_info).exists():
|
|
||||||
error = _("Name already taken.")
|
error = _("Name already taken.")
|
||||||
ppassword = p_form.cleaned_data['password']
|
ppassword = p_form.cleaned_data['password']
|
||||||
if error is None:
|
if error is None:
|
||||||
|
@ -141,20 +137,18 @@ def leave_team(request, event_slug):
|
||||||
player = EventPlayer.objects.get(user=request.user, event=event_info)
|
player = EventPlayer.objects.get(user=request.user, event=event_info)
|
||||||
team = Team.objects.get(event=event_info, name=player.team.name)
|
team = Team.objects.get(event=event_info, name=player.team.name)
|
||||||
|
|
||||||
player.team = None
|
|
||||||
player.save()
|
|
||||||
members = EventPlayer.objects.filter(team=team, event=event_info)
|
|
||||||
if members.count() == 0:
|
|
||||||
team.delete()
|
|
||||||
else:
|
|
||||||
team.score -= player.score
|
team.score -= player.score
|
||||||
team.save()
|
team.save()
|
||||||
|
player.team = None
|
||||||
solved = CTF_flags.objects.filter(user=player.user, ctf__event=event_info)
|
solved = CTF_flags.objects.filter(user=player.user, ctf__event=event_info)
|
||||||
player.score = 0
|
player.score = 0
|
||||||
solved.delete()
|
solved.delete()
|
||||||
player.save()
|
player.save()
|
||||||
|
|
||||||
|
members = EventPlayer.objects.filter(team=team, event=event_info)
|
||||||
|
if members.count() == 0:
|
||||||
|
team.delete()
|
||||||
|
|
||||||
return redirect('events:event_info', event_slug=event_slug)
|
return redirect('events:event_info', event_slug=event_slug)
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
|
Loading…
Reference in New Issue