mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-02-06 18:53:03 +00:00
45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
|
from django import forms
|
||
|
from django.utils.translation import gettext_lazy as _
|
||
|
|
||
|
from member.models import TFJMUser
|
||
|
from tfjm.inputs import DatePickerInput, DateTimePickerInput, AmountInput
|
||
|
from tournament.models import Tournament, Team
|
||
|
|
||
|
|
||
|
class TournamentForm(forms.ModelForm):
|
||
|
class Meta:
|
||
|
model = Tournament
|
||
|
fields = '__all__'
|
||
|
widgets = {
|
||
|
"price": AmountInput(),
|
||
|
"date_start": DatePickerInput(),
|
||
|
"date_end": DatePickerInput(),
|
||
|
"date_inscription": DateTimePickerInput(),
|
||
|
"date_solutions": DateTimePickerInput(),
|
||
|
"date_syntheses": DateTimePickerInput(),
|
||
|
}
|
||
|
|
||
|
|
||
|
class OrganizerForm(forms.ModelForm):
|
||
|
class Meta:
|
||
|
model = TFJMUser
|
||
|
fields = ('last_name', 'first_name', 'email', 'is_superuser',)
|
||
|
|
||
|
def save(self, commit=True):
|
||
|
user = self.instance
|
||
|
user.role = '0admin' if user.is_superuser else '1organizer'
|
||
|
super().save(commit)
|
||
|
|
||
|
|
||
|
class TeamForm(forms.ModelForm):
|
||
|
class Meta:
|
||
|
model = Team
|
||
|
fields = ('name', 'trigram', 'tournament',)
|
||
|
|
||
|
|
||
|
class JoinTeam(forms.Form):
|
||
|
access_code = forms.CharField(
|
||
|
label=_("Access code"),
|
||
|
max_length=6,
|
||
|
)
|