From e774921c526c3a12ac8a214a6032c9eb8c521d37 Mon Sep 17 00:00:00 2001 From: Danhia Date: Tue, 14 Dec 2021 20:35:59 +0100 Subject: [PATCH] little fix for flag length + restrict access for unpublished challenges --- src/ctfs/templates/ctfs/ctf_info.html | 8 +++++++- src/ctfs/views.py | 10 +++++----- src/events/templates/events/ctf_info.html | 2 +- src/events/views.py | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/ctfs/templates/ctfs/ctf_info.html b/src/ctfs/templates/ctfs/ctf_info.html index 228d7a1..19a7ef5 100644 --- a/src/ctfs/templates/ctfs/ctf_info.html +++ b/src/ctfs/templates/ctfs/ctf_info.html @@ -8,6 +8,11 @@

{{ ctf.name }}

{% trans "Published date" %} : {{ ctf.pub_date }} + {% if date < ctf.pub_date %} +
+ {% trans "Challenge is not yet available." %} +
+ {% else %}
{% if description %} {{ description|safe }} @@ -37,13 +42,14 @@ {% endif %}
{% csrf_token %} - +
{% endif %} {% endif %}
+ {% endif %}

{% trans "Solved by" %}

diff --git a/src/ctfs/views.py b/src/ctfs/views.py index 7f15c08..a5de830 100644 --- a/src/ctfs/views.py +++ b/src/ctfs/views.py @@ -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()}) diff --git a/src/events/templates/events/ctf_info.html b/src/events/templates/events/ctf_info.html index 810440f..da5cba2 100644 --- a/src/events/templates/events/ctf_info.html +++ b/src/events/templates/events/ctf_info.html @@ -53,7 +53,7 @@ {% endif %}
{% csrf_token %} - +
diff --git a/src/events/views.py b/src/events/views.py index df1c328..f3abe04 100644 --- a/src/events/views.py +++ b/src/events/views.py @@ -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