mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2024-12-25 20:22:22 +00:00
Use timezone
This commit is contained in:
parent
333b04a01b
commit
613fe2447d
@ -1,9 +1,9 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
|
from django.utils import timezone
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from member.models import TFJMUser, Solution, Synthesis
|
from member.models import TFJMUser, Solution, Synthesis
|
||||||
@ -62,7 +62,7 @@ class OrganizerForm(forms.ModelForm):
|
|||||||
|
|
||||||
class TeamForm(forms.ModelForm):
|
class TeamForm(forms.ModelForm):
|
||||||
tournament = forms.ModelChoiceField(
|
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:
|
class Meta:
|
||||||
@ -84,7 +84,7 @@ class TeamForm(forms.ModelForm):
|
|||||||
if Team.objects.filter(name=cleaned_data["name"], year=os.getenv("TFJM_YEAR")).exists():
|
if Team.objects.filter(name=cleaned_data["name"], year=os.getenv("TFJM_YEAR")).exists():
|
||||||
self.add_error("name", _("This name is already used."))
|
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."))
|
self.add_error("tournament", _("This tournament is already closed."))
|
||||||
|
|
||||||
return cleaned_data
|
return cleaned_data
|
||||||
|
Loading…
Reference in New Issue
Block a user