mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2024-12-24 19:02:23 +00:00
datetime are time-zoned
This commit is contained in:
parent
ecbbe46420
commit
72ca257bc3
@ -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
|
||||
|
@ -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"),
|
||||
)
|
||||
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user