diff --git a/apps/member/views.py b/apps/member/views.py index 6e088fe..be6de1c 100644 --- a/apps/member/views.py +++ b/apps/member/views.py @@ -1,5 +1,5 @@ import random -from datetime import datetime +from datetime import timezone from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.auth.models import AnonymousUser @@ -157,7 +157,7 @@ class DocumentView(LoginRequiredMixin, View): if isinstance(doc, Solution): for pool in doc.pools.all(): - if pool.round == 2 and datetime.now() < doc.tournament.date_solutions_2: + if pool.round == 2 and timezone.now() < doc.tournament.date_solutions_2: continue if self.request.user.team in pool.teams.all(): grant = True diff --git a/apps/tournament/models.py b/apps/tournament/models.py index 2a32b80..6880cd5 100644 --- a/apps/tournament/models.py +++ b/apps/tournament/models.py @@ -46,27 +46,27 @@ class Tournament(models.Model): ) date_inscription = models.DateTimeField( - default=datetime.now, + default=timezone.now, verbose_name=_("date of registration closing"), ) date_solutions = models.DateTimeField( - default=datetime.now, + default=timezone.now, verbose_name=_("date of maximal solution submission"), ) date_syntheses = models.DateTimeField( - default=datetime.now, + default=timezone.now, verbose_name=_("date of maximal syntheses submission for the first round"), ) date_solutions_2 = models.DateTimeField( - default=datetime.now, + default=timezone.now, verbose_name=_("date when solutions of round 2 are available"), ) date_syntheses_2 = models.DateTimeField( - default=datetime.now, + default=timezone.now, verbose_name=_("date of maximal syntheses submission for the second round"), ) diff --git a/apps/tournament/views.py b/apps/tournament/views.py index 9a50449..cc6d6e2 100644 --- a/apps/tournament/views.py +++ b/apps/tournament/views.py @@ -1,6 +1,6 @@ import random import zipfile -from datetime import datetime +from datetime import timezone from io import BytesIO from django.contrib.auth.mixins import LoginRequiredMixin @@ -237,7 +237,7 @@ class SolutionsView(TeamMixin, BaseFormView, SingleTableView): solution.team = self.request.user.team solution.final = solution.team.selected_for_final - if datetime.now() > solution.tournament.date_solutions: + if timezone.now() > solution.tournament.date_solutions: form.add_error('file', _("You can't publish your solution anymore. Deadline: {date:%m-%d-%Y %h:%M}.") .format(date=solution.tournament.date_solutions)) return super().form_invalid(form) @@ -341,13 +341,13 @@ class SynthesesView(TeamMixin, BaseFormView, SingleTableView): synthesis.team = self.request.user.team synthesis.final = synthesis.team.selected_for_final - if synthesis.round == '1' and datetime.now() > synthesis.tournament.date_syntheses: + if synthesis.round == '1' and timezone.now() > synthesis.tournament.date_syntheses: 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)) return super().form_invalid(form) - if synthesis.round == '2' and datetime.now() > synthesis.tournament.date_syntheses_2: + if synthesis.round == '2' and timezone.now() > synthesis.tournament.date_syntheses_2: 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))