added option to open team to automatching
This commit is contained in:
parent
dae0a87548
commit
c8a171fa76
|
@ -20,14 +20,6 @@
|
|||
</div>
|
||||
<div class="ctf-footer">
|
||||
{% if request.user.is_authenticated %}
|
||||
|
||||
{% if subisover == True %}
|
||||
<span class="message error-msg">{% trans "Subscriptions is over." %}</span>
|
||||
{% endif %}
|
||||
{% if alreadyregistered == True %}
|
||||
<span class="message error-msg">{% trans "You're already registered to this event." %}</span>
|
||||
{% endif %}
|
||||
|
||||
{% if congrat == True %}
|
||||
<p>{% trans "Congratulation !" %}</p>
|
||||
{% elif alreadyflag == True %}
|
||||
|
@ -38,6 +30,8 @@
|
|||
<p>{% trans "Error while processing your request. (Invalid Form)" %}</p>
|
||||
{% elif notsub == True %}
|
||||
<span class="message error-msg">{% trans "Error: you're not registered to this event, so you can't register scores, fucking logic." %}</span>
|
||||
{% elif noteam == True %}
|
||||
<span class="message error-msg">{% trans "This is a team event, please create or join a team before submitting flags." %}</span>
|
||||
{% if ctf.ctf_url %}
|
||||
<a class="begin-ctf-link" target="_blank" href="{{ ctf.ctf_url }}">{% trans "Start the challenge" %}</a></br>
|
||||
{% elif ctf.file %}
|
||||
|
|
|
@ -45,14 +45,28 @@
|
|||
{% for p in members %}
|
||||
<li class="list-group-item"><a class="profile_link" href="{% url 'accounts:profile' user_name=p.user.username %}">{{ p.user.username }}</a></li>
|
||||
{% endfor %}
|
||||
<form method='POST' action="{% url 'events:leave_team' event_slug=player.event.slug %}">
|
||||
</ul>
|
||||
<form method='POST' action="{% url 'events:leave_team' event_slug=player.event.slug %}">
|
||||
{%csrf_token%}
|
||||
<li class="list-group-item">
|
||||
<input class="form-control" type="submit" value="{% trans "Leave Team" %}">
|
||||
</li>
|
||||
</form>
|
||||
{% if player.team.auto == False and player.event.auto_match == True %}
|
||||
<form method='POST' action="{% url 'events:open_team' event_slug=player.event.slug %}">
|
||||
{%csrf_token%}
|
||||
<li class="list-group-item">
|
||||
<input class="form-control" type="submit" value="{% trans "Leave Team" %}">
|
||||
<input class="form-control" type="submit" value="{% trans "Open to automatching" %}">
|
||||
</li>
|
||||
</form>
|
||||
|
||||
</ul>
|
||||
</form>
|
||||
{% elif player.event.auto_match == True %}
|
||||
<form method='POST' action="{% url 'events:close_team' event_slug=player.event.slug %}">
|
||||
{%csrf_token%}
|
||||
<li class="list-group-item">
|
||||
<input class="form-control" type="submit" value="{% trans "Close to automatching" %}">
|
||||
</li>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -17,4 +17,6 @@ urlpatterns = [
|
|||
path('<str:event_slug>/manage_team', views.manage_team, name='manage_team'),
|
||||
path('<str:event_slug>/leave_team', views.leave_team, name='leave_team'),
|
||||
path('find_team/<str:event_slug>', views.find_team, name='find_team'),
|
||||
path('<str:event_slug>/open_team', views.open_team, name='open_team'),
|
||||
path('<str:event_slug>/close_team', views.close_team, name='close_team'),
|
||||
]
|
||||
|
|
|
@ -29,6 +29,7 @@ def events(request):
|
|||
def chall_event_info(request, event_slug, chall_slug):
|
||||
event_info = get_object_or_404(Event, slug=event_slug)
|
||||
ctf_info = get_object_or_404(CTF, event__slug=event_info.slug, slug=chall_slug)
|
||||
|
||||
if timezone.now() < ctf_info.pub_date:
|
||||
return redirect('events:event_info', event_slug=event_slug)
|
||||
eventisover = False
|
||||
|
@ -37,6 +38,7 @@ def chall_event_info(request, event_slug, chall_slug):
|
|||
wrongflag = False
|
||||
errorform = False
|
||||
notsub = False
|
||||
noteam = False
|
||||
player = None
|
||||
if request.user.is_authenticated and not request.user.is_staff:
|
||||
player = EventPlayer.objects.filter(event=event_info, user=request.user)
|
||||
|
@ -56,6 +58,8 @@ def chall_event_info(request, event_slug, chall_slug):
|
|||
errorform = True
|
||||
if request.GET.get('NotRegistered'):
|
||||
notsub = True
|
||||
if request.GET.get('NoTeam'):
|
||||
noteam = True
|
||||
solved_challs = CTF_flags.objects.filter(ctf=ctf_info).order_by('flag_date')
|
||||
solved_list = []
|
||||
for s in solved_challs:
|
||||
|
@ -65,7 +69,7 @@ def chall_event_info(request, event_slug, chall_slug):
|
|||
solved_list.append([s.user, s.flag_date])
|
||||
description = get_description_by_lang(ctf_info)
|
||||
return render(request, 'events/ctf_info.html', { 'ctf' : ctf_info, 'event':event_info, 'solved_list': solved_list, 'description': description, 'eventisover': eventisover, 'alreadyflag': alreadyflag,
|
||||
'congrat': congrat, 'wrongflag': wrongflag, 'errorform': errorform, 'notsub': notsub})
|
||||
'congrat': congrat, 'wrongflag': wrongflag, 'errorform': errorform, 'notsub': notsub, 'noteam':noteam})
|
||||
|
||||
def event(request, event_slug):
|
||||
event_info = get_object_or_404(Event, slug=event_slug)
|
||||
|
@ -126,6 +130,9 @@ def submit_event_flag(request, event_slug, chall_slug):
|
|||
player = EventPlayer.objects.get(user=request.user, event=ev)
|
||||
|
||||
if player:
|
||||
if ev.team_size > 1 and player.team is None:
|
||||
response['Location'] += '?NoTeam=1'
|
||||
return response
|
||||
if ev.team_size == 1 and CTF_flags.objects.filter(user=request.user, ctf=ctf_info):
|
||||
flagged = True
|
||||
else:
|
||||
|
@ -187,8 +194,6 @@ 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})
|
||||
return redirect('events:event_info', event_slug=event_slug)
|
||||
|
||||
|
||||
|
|
|
@ -48,7 +48,6 @@ def join_team(request, event_slug):
|
|||
player.save()
|
||||
else:
|
||||
return render(request, 'events/join_team.html', {'event' : ev, 'logged': True, 'wrongpwd': False, 'registered' : True, 'notexist' : False})
|
||||
return redirect('events:event_info', event_slug=event_slug)
|
||||
|
||||
@login_required
|
||||
def team_info(request, name, event_slug):
|
||||
|
@ -175,4 +174,28 @@ def find_team(request, event_slug):
|
|||
player.team = team
|
||||
player.save()
|
||||
|
||||
return redirect('events:event_info', event_slug=event_slug)
|
||||
return redirect('events:event_info', event_slug=event_slug)
|
||||
|
||||
@login_required
|
||||
def open_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})
|
||||
|
||||
player.team.auto = True
|
||||
player.team.save()
|
||||
return redirect('events:manage_team', event_slug=event_slug)
|
||||
|
||||
@login_required
|
||||
def close_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})
|
||||
|
||||
player.team.auto = False
|
||||
player.team.save()
|
||||
return redirect('events:manage_team', event_slug=event_slug)
|
Loading…
Reference in New Issue