2020-02-17 15:52:31 +01:00
|
|
|
# coding=UTF-8
|
|
|
|
|
|
|
|
from django import forms
|
|
|
|
from datetime import date
|
2021-06-20 18:19:33 +02:00
|
|
|
from .models import Routine, RoutineSkill, Chrono
|
2020-02-17 15:52:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
class RoutineForm(forms.ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = Routine
|
2021-12-05 12:43:30 +01:00
|
|
|
fields = ("long_label", "short_label", "difficulty", "level", "active")
|
2020-02-17 15:52:31 +01:00
|
|
|
widgets = {
|
|
|
|
# Champs obligatoires de la classe mère.
|
2021-12-05 12:43:30 +01:00
|
|
|
"long_label": forms.TextInput(
|
2020-02-17 15:52:31 +01:00
|
|
|
attrs={"class": "form-control", "placeholder": "Routine's long name"}
|
|
|
|
),
|
2021-12-05 12:43:30 +01:00
|
|
|
"short_label": forms.TextInput(
|
2020-02-17 15:52:31 +01:00
|
|
|
attrs={"class": "form-control", "placeholder": "Routine's short name"}
|
|
|
|
),
|
|
|
|
"difficulty": forms.HiddenInput(),
|
|
|
|
"level": forms.HiddenInput(),
|
|
|
|
"active": forms.HiddenInput(),
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class ChronoForm(forms.ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = Chrono
|
|
|
|
fields = ("routine", "routine_type", "gymnast", "date", "score")
|
|
|
|
widgets = {
|
|
|
|
"gymnast": forms.HiddenInput(),
|
|
|
|
"routine": forms.HiddenInput(),
|
|
|
|
"routine_type": forms.Select(attrs={"class": "form-control"}),
|
|
|
|
"date": forms.TextInput(
|
|
|
|
attrs={
|
|
|
|
"class": "form-control datepicker",
|
|
|
|
"placeholder": date.today().strftime("%Y-%m-%d"),
|
|
|
|
"value": date.today().strftime("%Y-%m-%d"),
|
|
|
|
}
|
|
|
|
),
|
|
|
|
"score": forms.TextInput(
|
|
|
|
attrs={"class": "form-control", "placeholder": "xx,xx"}
|
|
|
|
),
|
|
|
|
}
|
|
|
|
|
|
|
|
gymnast_related = forms.CharField(
|
|
|
|
widget=forms.TextInput(
|
|
|
|
attrs={
|
|
|
|
"class": "form-control",
|
|
|
|
"placeholder": "Searching gymnast…",
|
|
|
|
"data-ref": "#id_gymnast",
|
|
|
|
}
|
|
|
|
)
|
|
|
|
)
|
|
|
|
routine_related = forms.CharField(
|
|
|
|
widget=forms.TextInput(
|
|
|
|
attrs={
|
|
|
|
"class": "form-control",
|
|
|
|
"placeholder": "Searching routine…",
|
|
|
|
"data-ref": "#id_routine",
|
|
|
|
}
|
|
|
|
)
|
|
|
|
)
|