little fix for flag length + restrict access for unpublished challenges

This commit is contained in:
Danhia 2021-12-14 20:35:59 +01:00
parent 8ae6d83450
commit e774921c52
4 changed files with 14 additions and 8 deletions

View File

@ -8,6 +8,11 @@
<h3>{{ ctf.name }}</h3>
<small>{% trans "Published date" %} : {{ ctf.pub_date }}</small>
</div>
{% if date < ctf.pub_date %}
<div class="ctf-body">
{% trans "Challenge is not yet available." %}
</div>
{% else %}
<div class="ctf-body">
{% if description %}
{{ description|safe }}
@ -37,13 +42,14 @@
{% endif %}
<form method="post" class="submitflag-form">
{% csrf_token %}
<input type="text" name="flag" maxlength="48" required="" id="id_flag">
<input type="text" name="flag" maxlength="100" required="" id="id_flag">
<input class="form-control" type="submit" value=">">
</form>
{% endif %}
{% endif %}
</div>
{% endif %}
</div>
<div>
<h4>{% trans "Solved by" %}</h4>

View File

@ -46,12 +46,12 @@ def ctf(request, cat_slug, ctf_slug):
profil.last_submission_date = timezone.now()
profil.score += ctf_info.points
profil.save()
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'valitated': True, 'description': description})
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'valitated': True, 'description': description, 'date': timezone.now()})
else:
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'failed': True, 'description': description})
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'failed': True, 'description': description, 'date': timezone.now()})
else:
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'alvalitated': True, 'description': description})
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'alvalitated': True, 'description': description, 'date': timezone.now()})
else:
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'description': description})
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'description': description, 'date': timezone.now()})
else:
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'alvalitated': flagged, 'description': description})
return render(request, 'ctfs/ctf_info.html', { 'ctf' : ctf_info, 'solved_list': solved_list, 'alvalitated': flagged, 'description': description, 'date': timezone.now()})

View File

@ -53,7 +53,7 @@
{% endif %}
<form method="post" action="{% url 'events:submit_event_flag' event_slug=event.slug chall_slug=ctf.slug %}" class="submitflag-form">
{% csrf_token %}
<input type="text" name="flag" maxlength="48" required="" id="id_flag">
<input type="text" name="flag" maxlength="100" required="" id="id_flag">
<input class="form-control" type="submit" value=">">
</form>

View File

@ -27,7 +27,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.start_date:
if timezone.now() < ctf_info.pub_date:
return redirect('events:event_info', event_slug=event_slug)
eventisover = False
alreadyflag = False