From 36bbe95fc33d7475fde4d7235f17faffdfdffd0f Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Tue, 5 May 2020 23:06:32 +0200 Subject: [PATCH] Better times --- apps/tournament/views.py | 13 +++++++------ templates/tournament/tournament_detail.html | 8 +++++++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/apps/tournament/views.py b/apps/tournament/views.py index 7cebc6e..a9d2c72 100644 --- a/apps/tournament/views.py +++ b/apps/tournament/views.py @@ -1,5 +1,6 @@ import random import zipfile +from datetime import timedelta from io import BytesIO from django.contrib.auth.mixins import LoginRequiredMixin @@ -239,9 +240,9 @@ class SolutionsView(TeamMixin, BaseFormView, SingleTableView): solution.team = self.request.user.team solution.final = solution.team.selected_for_final - if timezone.now() > solution.tournament.date_solutions: + if timezone.now() > solution.tournament.date_solutions + timedelta(minutes=30): form.add_error('file', _("You can't publish your solution anymore. Deadline: {date:%m-%d-%Y %H:%M}.") - .format(date=solution.tournament.date_solutions)) + .format(date=timezone.localtime(solution.tournament.date_solutions))) return super().form_invalid(form) prev_sol = Solution.objects.filter(problem=solution.problem, team=solution.team, final=solution.final) @@ -347,16 +348,16 @@ class SynthesesView(TeamMixin, BaseFormView, SingleTableView): synthesis.team = self.request.user.team synthesis.final = synthesis.team.selected_for_final - if synthesis.round == '1' and timezone.now() > synthesis.tournament.date_syntheses: + if synthesis.round == '1' and timezone.now() > (synthesis.tournament.date_syntheses + timedelta(minutes=30)): form.add_error('file', _("You can't publish your synthesis anymore for the first round." " Deadline: {date:%m-%d-%Y %H:%M}.") - .format(date=synthesis.tournament.date_syntheses)) + .format(date=timezone.localtime(synthesis.tournament.date_syntheses))) return super().form_invalid(form) - if synthesis.round == '2' and timezone.now() > synthesis.tournament.date_syntheses_2: + if synthesis.round == '2' and timezone.now() > synthesis.tournament.date_syntheses_2 + timedelta(minutes=30): form.add_error('file', _("You can't publish your synthesis anymore for the second round." " Deadline: {date:%m-%d-%Y %H:%M}.") - .format(date=synthesis.tournament.date_syntheses_2)) + .format(date=timezone.localtime(synthesis.tournament.date_syntheses_2))) return super().form_invalid(form) prev_syn = Synthesis.objects.filter(team=synthesis.team, round=synthesis.round, source=synthesis.source, diff --git a/templates/tournament/tournament_detail.html b/templates/tournament/tournament_detail.html index 89c0eaa..2c3b617 100644 --- a/templates/tournament/tournament_detail.html +++ b/templates/tournament/tournament_detail.html @@ -30,9 +30,15 @@
{% trans 'date of maximal solution submission'|capfirst %}
{{ tournament.date_solutions }}
-
{% trans 'date of maximal syntheses submission'|capfirst %}
+
{% trans 'date of maximal syntheses submission for the first round'|capfirst %}
{{ tournament.date_syntheses }}
+
{% trans 'date when solutions of round 2 are available'|capfirst %}
+
{{ tournament.date_solutions_2 }}
+ +
{% trans 'date of maximal syntheses submission for the second round'|capfirst %}
+
{{ tournament.date_syntheses_2 }}
+
{% trans 'description'|capfirst %}
{{ tournament.description }}