1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-07-03 17:22:51 +02:00

Create tournaments

This commit is contained in:
Yohann D'ANELLO
2020-12-31 12:13:42 +01:00
parent 03144ae58e
commit 4e29b4830a
13 changed files with 140 additions and 97 deletions

View File

@ -3,11 +3,13 @@
import re
from bootstrap_datepicker_plus import DatePickerInput, DateTimePickerInput
from django import forms
from django.core.exceptions import ValidationError
from django.utils import formats
from django.utils.translation import gettext_lazy as _
from .models import Participation, Team
from .models import Participation, Team, Tournament
class TeamForm(forms.ModelForm):
@ -85,3 +87,25 @@ class ValidateParticipationForm(forms.Form):
label=_("Message to address to the team:"),
widget=forms.Textarea(),
)
class TournamentForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["date_start"].widget = DatePickerInput(
format=formats.get_format_lazy(format_type="DATE_INPUT_FORMATS", use_l10n=True)[0])
self.fields["date_end"].widget = DatePickerInput(
format=formats.get_format_lazy(format_type="DATE_INPUT_FORMATS", use_l10n=True)[0])
self.fields["inscription_limit"].widget = DateTimePickerInput(
format=formats.get_format_lazy(format_type="DATETIME_INPUT_FORMATS", use_l10n=True)[0])
self.fields["solution_limit"].widget = DateTimePickerInput(
format=formats.get_format_lazy(format_type="DATETIME_INPUT_FORMATS", use_l10n=True)[0])
self.fields["syntheses_first_phase_limit"].widget = DateTimePickerInput(
format=formats.get_format_lazy(format_type="DATETIME_INPUT_FORMATS", use_l10n=True)[0])
self.fields["syntheses_second_phase_limit"].widget = DateTimePickerInput(
format=formats.get_format_lazy(format_type="DATETIME_INPUT_FORMATS", use_l10n=True)[0])
class Meta:
model = Tournament
fields = '__all__'