2022-01-07 18:08:39 +01:00
from datetime import date
2021-12-09 16:53:44 +01:00
from django import forms
2021-12-19 09:30:51 +01:00
from . models import (
Chrono ,
LearnedSkill ,
Point ,
Accident ,
MindState ,
GymnastHasRoutine ,
HeightWeight ,
2021-12-24 07:48:46 +01:00
NumberOfRoutineDone ,
2022-01-05 18:49:04 +01:00
Plan ,
2021-12-19 09:30:51 +01:00
)
2021-12-09 16:53:44 +01:00
class ChronoForm ( forms . ModelForm ) :
class Meta :
model = Chrono
2021-12-24 07:48:46 +01:00
fields = ( " gymnast " , " date " , " chrono_type " , " score_type " , " score " , " tof " )
2021-12-09 16:53:44 +01:00
widgets = {
2021-12-19 09:30:51 +01:00
" gymnast " : forms . HiddenInput ( ) ,
" date " : forms . TextInput (
2021-12-09 16:53:44 +01:00
attrs = {
2022-01-31 17:37:51 +01:00
" class " : " form-control datepicker " ,
2021-12-19 09:30:51 +01:00
" placeholder " : date . today ( ) . strftime ( " % Y- % m- %d " ) ,
" value " : date . today ( ) . strftime ( " % Y- % m- %d " ) ,
2021-12-09 16:53:44 +01:00
}
) ,
2022-01-06 17:59:21 +01:00
" chrono_type " : forms . Select ( attrs = { " class " : " form-control selectpicker " } ) ,
" score_type " : forms . Select ( attrs = { " class " : " form-control selectpicker " } ) ,
2022-01-25 19:03:43 +01:00
" score " : forms . NumberInput (
attrs = { " class " : " form-control " , " placeholder " : " xx,xxx " , " min " : " 0.01 " , " step " : " 0.01 " }
2021-12-09 16:53:44 +01:00
) ,
2021-12-19 09:30:51 +01:00
" tof " : forms . HiddenInput ( ) ,
2021-12-09 16:53:44 +01:00
}
gymnast_related = forms . CharField (
widget = forms . TextInput (
attrs = {
2021-12-19 09:30:51 +01:00
" class " : " form-control " ,
" placeholder " : " Searching gymnast… " ,
" data-ref " : " #id_gymnast " ,
2021-12-09 16:53:44 +01:00
}
)
)
class LearnedSkillForm ( forms . ModelForm ) :
class Meta :
model = LearnedSkill
2021-12-19 09:30:51 +01:00
fields = ( " gymnast " , " skill " , " cando " , " date " )
2021-12-09 16:53:44 +01:00
widgets = {
2021-12-19 09:30:51 +01:00
" gymnast " : forms . HiddenInput ( ) ,
" skill " : forms . HiddenInput ( ) ,
" date " : forms . TextInput (
2021-12-09 16:53:44 +01:00
attrs = {
2021-12-19 09:30:51 +01:00
" class " : " form-control datepicker " ,
" placeholder " : date . today ( ) . strftime ( " % Y- % m- %d " ) ,
" value " : date . today ( ) . strftime ( " % Y- % m- %d " ) ,
2021-12-09 16:53:44 +01:00
}
) ,
2022-01-06 17:59:21 +01:00
" cando " : forms . Select ( attrs = { " class " : " form-control selectpicker " } ) ,
2021-12-09 16:53:44 +01:00
}
gymnast_related = forms . CharField (
widget = forms . TextInput (
attrs = {
2021-12-19 09:30:51 +01:00
" class " : " form-control " ,
" placeholder " : " Searching gymnast… " ,
" data-ref " : " #id_gymnast " ,
2021-12-09 16:53:44 +01:00
}
)
)
skill_related = forms . CharField (
widget = forms . TextInput (
attrs = {
2021-12-19 09:30:51 +01:00
" class " : " form-control " ,
" placeholder " : " Searching skill… " ,
" data-ref " : " #id_skill " ,
2021-12-09 16:53:44 +01:00
}
)
)
class ScoreForm ( forms . ModelForm ) :
class Meta :
ROUTINETYPE_CHOICE = (
2021-12-19 09:30:51 +01:00
( 0 , " Routine 1 " ) ,
( 1 , " Routine 2 " ) ,
( 2 , " Final ' s routine " ) ,
2021-12-09 16:53:44 +01:00
)
model = Point
fields = (
2021-12-19 09:30:51 +01:00
" gymnast " ,
" event " ,
" routine_type " ,
" point_difficulty " ,
" point_time_of_flight " ,
" point_execution " ,
" point_horizontal_displacement " ,
" penality " ,
" total " ,
2021-12-09 16:53:44 +01:00
)
widgets = {
2021-12-19 09:30:51 +01:00
" gymnast " : forms . HiddenInput ( ) ,
" event " : forms . HiddenInput ( ) ,
2022-01-06 17:59:21 +01:00
" routine_type " : forms . Select ( attrs = { " class " : " form-control selectpicker " } ) ,
2021-12-19 09:30:51 +01:00
" point_execution " : forms . NumberInput (
2022-01-07 18:08:39 +01:00
attrs = { " class " : " form-control " , " placeholder " : " xx,xx " , " min " : " 0 " }
2021-12-09 16:53:44 +01:00
) ,
2021-12-19 09:30:51 +01:00
" point_difficulty " : forms . NumberInput (
2022-01-07 18:08:39 +01:00
attrs = { " class " : " form-control " , " placeholder " : " xx,xx " , " min " : " 0 " }
2021-12-09 16:53:44 +01:00
) ,
2021-12-19 09:30:51 +01:00
" point_time_of_flight " : forms . NumberInput (
2022-01-07 18:08:39 +01:00
attrs = { " class " : " form-control " , " placeholder " : " xx,xx " , " min " : " 0 " }
2021-12-09 16:53:44 +01:00
) ,
2021-12-19 09:30:51 +01:00
" point_horizontal_displacement " : forms . NumberInput (
2022-01-07 18:08:39 +01:00
attrs = { " class " : " form-control " , " placeholder " : " x,xx " , " min " : " 0 " }
2021-12-09 16:53:44 +01:00
) ,
2021-12-19 09:30:51 +01:00
" penality " : forms . NumberInput (
2022-01-03 09:56:08 +01:00
attrs = {
" class " : " form-control " ,
2022-01-07 18:08:39 +01:00
" placeholder " : " xx,xx " ,
2022-01-03 09:56:08 +01:00
" value " : " 0 " ,
2022-01-07 18:08:39 +01:00
" min " : " 0 " ,
2022-01-03 09:56:08 +01:00
}
2021-12-09 16:53:44 +01:00
) ,
2021-12-19 09:30:51 +01:00
" total " : forms . TextInput (
2021-12-09 16:53:44 +01:00
attrs = {
2021-12-19 09:30:51 +01:00
" class " : " form-control " ,
" placeholder " : " 000,000 " ,
" readonly " : " readonly " ,
" maxlength " : " 6 " ,
2021-12-09 16:53:44 +01:00
}
) ,
}
gymnast_related = forms . CharField (
2022-02-02 12:37:18 +01:00
widget = forms . TextInput (
attrs = {
2021-12-19 09:30:51 +01:00
" class " : " form-control " ,
" placeholder " : " Searching… " ,
" data-ref " : " #id_gymnast " ,
2021-12-09 16:53:44 +01:00
}
)
)
2022-01-05 18:49:04 +01:00
2021-12-09 16:53:44 +01:00
event_related = forms . CharField (
2022-02-01 17:28:57 +01:00
widget = forms . TextInput (
attrs = {
2021-12-19 09:30:51 +01:00
" class " : " form-control " ,
" placeholder " : " Searching… " ,
" data-ref " : " #id_event " ,
2021-12-09 16:53:44 +01:00
}
)
)
2022-02-02 12:37:18 +01:00
add_to_chrono = forms . NullBooleanField (
required = False ,
widget = forms . CheckboxInput (
2022-02-01 17:28:57 +01:00
attrs = { " class " : " form-control form-check-input ml-0 mt-0 " }
)
)
2021-12-09 16:53:44 +01:00
class AccidentForm ( forms . ModelForm ) :
class Meta :
model = Accident
2021-12-19 09:30:51 +01:00
fields = ( " gymnast " , " date " , " nb_week_off " , " informations " )
2021-12-09 16:53:44 +01:00
widgets = {
2021-12-19 09:30:51 +01:00
" date " : forms . DateInput (
2021-12-09 16:53:44 +01:00
attrs = {
2021-12-19 09:30:51 +01:00
" class " : " form-control datepicker " ,
" placeholder " : date . today ( ) . strftime ( " % Y- % m- %d " ) ,
" value " : date . today ( ) . strftime ( " % Y- % m- %d " ) ,
2021-12-09 16:53:44 +01:00
}
) ,
2021-12-19 09:30:51 +01:00
" gymnast " : forms . HiddenInput ( ) ,
" skill " : forms . HiddenInput ( ) ,
" nb_week_off " : forms . NumberInput (
attrs = { " class " : " form-control " , " placeholder " : " xx " }
2021-12-09 16:53:44 +01:00
) ,
2021-12-19 09:30:51 +01:00
" informations " : forms . Textarea (
2021-12-09 16:53:44 +01:00
attrs = {
2021-12-19 09:30:51 +01:00
" class " : " form-control " ,
2022-01-07 18:08:39 +01:00
" placeholder " : " Informations about accident: context (why, where, …), consequencies, re-education exercices, … " , # pylint: disable=line-too-long
2021-12-09 16:53:44 +01:00
}
) ,
}
gymnast_related = forms . CharField (
widget = forms . TextInput (
attrs = {
2021-12-19 09:30:51 +01:00
" class " : " form-control " ,
" placeholder " : " Searching gymnast… " ,
" data-ref " : " #id_gymnast " ,
2021-12-09 16:53:44 +01:00
}
)
)
2022-01-05 18:49:04 +01:00
2021-12-09 16:53:44 +01:00
skill_related = forms . CharField (
2021-12-13 15:51:07 +01:00
required = False ,
2021-12-09 16:53:44 +01:00
widget = forms . TextInput (
attrs = {
2021-12-19 09:30:51 +01:00
" class " : " form-control " ,
" placeholder " : " Searching skill… " ,
" data-ref " : " #id_skill " ,
2021-12-09 16:53:44 +01:00
}
2021-12-19 09:30:51 +01:00
) ,
2021-12-09 16:53:44 +01:00
)
class MindStateForm ( forms . ModelForm ) :
class Meta :
model = MindState
2021-12-19 09:30:51 +01:00
fields = ( " gymnast " , " date " , " score " , " informations " )
2021-12-09 16:53:44 +01:00
widgets = {
2021-12-19 09:30:51 +01:00
" gymnast " : forms . HiddenInput ( ) ,
" date " : forms . TextInput (
2021-12-09 16:53:44 +01:00
attrs = {
2021-12-19 09:30:51 +01:00
" class " : " form-control datepicker " ,
" placeholder " : date . today ( ) . strftime ( " % Y- % m- %d " ) ,
" value " : date . today ( ) . strftime ( " % Y- % m- %d " ) ,
2021-12-09 16:53:44 +01:00
}
) ,
2021-12-19 09:30:51 +01:00
" event " : forms . HiddenInput ( ) ,
" score " : forms . NumberInput (
2022-01-03 09:56:08 +01:00
attrs = {
2022-01-07 18:08:39 +01:00
" class " : " form-control " ,
" placeholder " : " x " ,
" min " : " 0 " ,
" max " : " 10 " ,
2022-01-03 09:56:08 +01:00
}
2021-12-09 16:53:44 +01:00
) ,
2021-12-19 09:30:51 +01:00
" informations " : forms . Textarea (
2021-12-09 16:53:44 +01:00
attrs = {
2021-12-19 09:30:51 +01:00
" class " : " form-control " ,
2022-01-07 19:28:33 +01:00
" placeholder " : " Informations about the psychological state of mind : context (why, where, …), possible consequencies, … " , # pylint: disable=line-too-long
2021-12-09 16:53:44 +01:00
}
) ,
}
gymnast_related = forms . CharField (
widget = forms . TextInput (
attrs = {
2021-12-19 09:30:51 +01:00
" class " : " form-control " ,
" placeholder " : " Searching gymnast… " ,
" data-ref " : " #id_gymnast " ,
2021-12-09 16:53:44 +01:00
}
)
)
event_related = forms . CharField (
required = False ,
widget = forms . TextInput (
attrs = {
2021-12-19 09:30:51 +01:00
" class " : " form-control " ,
" placeholder " : " Searching event… " ,
" data-ref " : " #id_event " ,
2021-12-09 16:53:44 +01:00
}
2021-12-19 09:30:51 +01:00
) ,
2021-12-09 16:53:44 +01:00
)
class GymnastHasRoutineForm ( forms . ModelForm ) :
class Meta :
model = GymnastHasRoutine
2021-12-19 09:30:51 +01:00
fields = ( " gymnast " , " routine " , " routine_type " , " datebegin " , " dateend " )
2021-12-09 16:53:44 +01:00
widgets = {
2021-12-19 09:30:51 +01:00
" gymnast " : forms . HiddenInput ( ) ,
" routine " : forms . HiddenInput ( ) ,
2022-01-06 17:59:21 +01:00
" routine_type " : forms . Select ( attrs = { " class " : " form-control selectpicker " } ) ,
2021-12-19 09:30:51 +01:00
" datebegin " : forms . DateInput (
attrs = {
" class " : " form-control datepicker " ,
}
) ,
" dateend " : forms . DateInput (
attrs = {
" class " : " form-control datepicker " ,
}
) ,
2021-12-09 16:53:44 +01:00
}
gymnast_related = forms . CharField (
widget = forms . TextInput (
attrs = {
2021-12-19 09:30:51 +01:00
" class " : " form-control " ,
" placeholder " : " Searching gymnast… " ,
" data-ref " : " #id_gymnast " ,
2021-12-09 16:53:44 +01:00
}
)
)
2022-01-05 18:49:04 +01:00
2021-12-09 16:53:44 +01:00
routine_related = forms . CharField (
widget = forms . TextInput (
attrs = {
2021-12-19 09:30:51 +01:00
" class " : " form-control " ,
" placeholder " : " Searching routine… " ,
" data-ref " : " #id_routine " ,
2021-12-09 16:53:44 +01:00
}
)
2021-12-14 17:16:49 +01:00
)
2021-12-19 09:30:51 +01:00
2021-12-14 17:16:49 +01:00
class HeightWeightForm ( forms . ModelForm ) :
"""
Formulaire d ' enregistrement d ' un couple taille / poids
"""
class Meta :
model = HeightWeight
2021-12-22 14:47:00 +01:00
fields = ( " gymnast " , " date " , " height " , " hips_height " , " weight " )
2021-12-14 17:16:49 +01:00
widgets = {
2021-12-19 09:30:51 +01:00
" gymnast " : forms . HiddenInput ( ) ,
" date " : forms . TextInput (
2021-12-14 17:16:49 +01:00
attrs = {
2021-12-19 09:30:51 +01:00
" class " : " form-control datepicker " ,
" placeholder " : date . today ( ) . strftime ( " % Y- % m- %d " ) ,
" value " : date . today ( ) . strftime ( " % Y- % m- %d " ) ,
2021-12-14 17:16:49 +01:00
}
) ,
2021-12-19 09:30:51 +01:00
" height " : forms . NumberInput (
2022-01-03 09:56:08 +01:00
attrs = {
" class " : " form-control " ,
" placeholder " : " xxx,x " ,
" min " : " 100 " ,
2022-01-07 18:08:39 +01:00
" max " : " 220 " ,
2022-01-03 09:56:08 +01:00
}
2021-12-14 17:16:49 +01:00
) ,
2021-12-22 14:47:00 +01:00
" hips_height " : forms . NumberInput (
2022-01-03 09:56:08 +01:00
attrs = {
" class " : " form-control " ,
" placeholder " : " xxx,x " ,
" min " : " 50 " ,
2022-01-07 18:08:39 +01:00
" max " : " 110 " ,
2022-01-03 09:56:08 +01:00
}
2021-12-22 14:47:00 +01:00
) ,
2021-12-19 09:30:51 +01:00
" weight " : forms . NumberInput (
2022-01-03 09:56:08 +01:00
attrs = {
" class " : " form-control " ,
" placeholder " : " xxx,x " ,
" min " : " 20 " ,
2022-01-07 18:08:39 +01:00
" max " : " 110 " ,
2022-01-03 09:56:08 +01:00
}
2021-12-14 17:16:49 +01:00
) ,
}
gymnast_related = forms . CharField (
widget = forms . TextInput (
attrs = {
2021-12-19 09:30:51 +01:00
" class " : " form-control " ,
" placeholder " : " Searching gymnast… " ,
" data-ref " : " #id_gymnast " ,
2021-12-14 17:16:49 +01:00
}
)
)
2021-12-24 07:48:46 +01:00
class NumberOfRoutineDoneForm ( forms . ModelForm ) :
class Meta :
model = NumberOfRoutineDone
2022-01-07 18:08:39 +01:00
fields = (
" gymnast " ,
" routine " ,
" routine_type " ,
" date " ,
" number_of_try " ,
" number_of_successes " ,
)
2021-12-24 07:48:46 +01:00
widgets = {
" gymnast " : forms . HiddenInput ( ) ,
" routine " : forms . HiddenInput ( ) ,
2022-01-06 17:59:21 +01:00
" routine_type " : forms . Select ( attrs = { " class " : " form-control selectpicker " } ) ,
2021-12-24 07:48:46 +01:00
" date " : forms . DateInput (
attrs = {
" class " : " form-control datepicker " ,
}
) ,
" number_of_try " : forms . NumberInput (
2022-01-03 09:56:08 +01:00
attrs = {
" class " : " form-control " ,
" placeholder " : " x " ,
" min " : " 0 " ,
2022-01-07 18:08:39 +01:00
" max " : " 50 " ,
2022-01-03 09:56:08 +01:00
}
2021-12-24 07:48:46 +01:00
) ,
" number_of_successes " : forms . NumberInput (
2022-01-03 09:56:08 +01:00
attrs = {
" class " : " form-control " ,
" placeholder " : " x " ,
" min " : " 0 " ,
2022-01-07 18:08:39 +01:00
" max " : " 50 " ,
2022-01-03 09:56:08 +01:00
}
2021-12-24 07:48:46 +01:00
) ,
}
gymnast_related = forms . CharField (
widget = forms . TextInput (
attrs = {
" class " : " form-control " ,
" placeholder " : " Searching gymnast… " ,
" data-ref " : " #id_gymnast " ,
}
)
)
2022-01-05 18:49:04 +01:00
2021-12-24 07:48:46 +01:00
routine_related = forms . CharField (
widget = forms . TextInput (
attrs = {
" class " : " form-control " ,
" placeholder " : " Searching routine… " ,
" data-ref " : " #id_routine " ,
}
)
2022-01-05 18:49:04 +01:00
)
class PlanForm ( forms . ModelForm ) :
"""
Formulaire d ' enregistrement d ' un plan ( gymnast qui doit faire un eductative pour une date X )
"""
class Meta :
model = Plan
2022-01-06 10:04:36 +01:00
fields = ( " date " , " gymnast " , " educative " , " cando " , " is_done " )
2022-01-05 18:49:04 +01:00
widgets = {
" gymnast " : forms . HiddenInput ( ) ,
" educative " : forms . HiddenInput ( ) ,
" date " : forms . TextInput (
attrs = {
" class " : " form-control datepicker " ,
" placeholder " : date . today ( ) . strftime ( " % Y- % m- %d " ) ,
" value " : date . today ( ) . strftime ( " % Y- % m- %d " ) ,
}
) ,
2022-01-06 10:04:36 +01:00
" cando " : forms . Select ( attrs = { " class " : " form-control selectpicker " } ) ,
" is_done " : forms . CheckboxInput (
attrs = { " class " : " form-control form-check-input ml-0 mt-0 " }
2022-01-07 18:08:39 +01:00
) ,
2022-01-05 18:49:04 +01:00
}
gymnast_related = forms . CharField (
widget = forms . TextInput (
attrs = {
" class " : " form-control " ,
" placeholder " : " Searching gymnast… " ,
" data-ref " : " #id_gymnast " ,
}
)
)
educative_related = forms . CharField (
widget = forms . TextInput (
attrs = {
" class " : " form-control " ,
" placeholder " : " Searching skill… " ,
" data-ref " : " #id_skill " ,
}
)
)