1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2024-12-25 07:02:22 +00:00

Use timezone

This commit is contained in:
Yohann D'ANELLO 2020-05-05 16:07:53 +02:00
parent 333b04a01b
commit 613fe2447d

View File

@ -1,9 +1,9 @@
import os
import re
from datetime import datetime
from django import forms
from django.db.models import Q
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from member.models import TFJMUser, Solution, Synthesis
@ -62,7 +62,7 @@ class OrganizerForm(forms.ModelForm):
class TeamForm(forms.ModelForm):
tournament = forms.ModelChoiceField(
Tournament.objects.filter(date_inscription__gte=datetime.today(), final=False),
Tournament.objects.filter(date_inscription__gte=timezone.now().date(), final=False),
)
class Meta:
@ -84,7 +84,7 @@ class TeamForm(forms.ModelForm):
if Team.objects.filter(name=cleaned_data["name"], year=os.getenv("TFJM_YEAR")).exists():
self.add_error("name", _("This name is already used."))
if cleaned_data["tournament"].date_inscription < datetime.today():
if cleaned_data["tournament"].date_inscription < timezone.now().date():
self.add_error("tournament", _("This tournament is already closed."))
return cleaned_data