175 lines
5.5 KiB
Python
175 lines
5.5 KiB
Python
"""Formulaires de gestion des données entrantes pour les gymnastes et accidents."""
|
|
|
|
from django import forms
|
|
|
|
from .models import (
|
|
Accident,
|
|
Gymnast,
|
|
GymnastHasRoutine,
|
|
)
|
|
|
|
from django.contrib.auth.models import User
|
|
|
|
|
|
class AccidentForm(forms.ModelForm):
|
|
class Meta:
|
|
model = Accident
|
|
fields = ("gymnast", "educative", "date", "content")
|
|
widgets = {
|
|
"date": forms.DateInput(
|
|
attrs={
|
|
"class": "form-control datepicker",
|
|
# "value": date.today().strftime("%Y-%m-%d"),
|
|
}
|
|
),
|
|
"gymnast": forms.HiddenInput(),
|
|
"educative": forms.HiddenInput(),
|
|
"content": forms.Textarea(
|
|
attrs={
|
|
"class": "form-control",
|
|
"placeholder": "Informations about accident: context (why, where, …), consequencies, …",
|
|
}
|
|
),
|
|
}
|
|
|
|
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_educative",
|
|
}
|
|
)
|
|
)
|
|
|
|
|
|
class UserForm(forms.ModelForm):
|
|
class Meta:
|
|
model = User
|
|
fields = (
|
|
"last_name",
|
|
"first_name",
|
|
"email",
|
|
"is_active",
|
|
"username",
|
|
)
|
|
|
|
|
|
class GymnastForm(forms.ModelForm):
|
|
|
|
lastname = forms.CharField(
|
|
widget=forms.TextInput(
|
|
attrs={"class": "form-control", "placeholder": "Lastname"}
|
|
)
|
|
)
|
|
firstname = forms.CharField(
|
|
widget=forms.TextInput(
|
|
attrs={"class": "form-control", "placeholder": "Firstname"}
|
|
)
|
|
)
|
|
email = forms.EmailField()
|
|
# is_active = forms.CheckboxInput()
|
|
|
|
class Meta:
|
|
model = Gymnast
|
|
fields = (
|
|
"id",
|
|
"birthdate",
|
|
"gender",
|
|
"address",
|
|
"postal",
|
|
"city",
|
|
"phone",
|
|
"gsm",
|
|
"gsm_main_responsible",
|
|
"email_main_responsible",
|
|
"gsm_second_responsible",
|
|
"email_second_responsible",
|
|
"orientation",
|
|
"picture",
|
|
"content",
|
|
)
|
|
|
|
widgets = {
|
|
"id": forms.HiddenInput(),
|
|
"lastname": forms.TextInput(
|
|
attrs={"class": "form-control", "placeholder": "Lastname"}
|
|
),
|
|
"firstname": forms.TextInput(
|
|
attrs={"class": "form-control", "placeholder": "Firstname"}
|
|
),
|
|
"birthdate": forms.DateInput(attrs={"class": "form-control datepicker"}),
|
|
"gender": forms.Select(attrs={"class": "form-control"}),
|
|
"address": forms.TextInput(attrs={"class": "form-control"}),
|
|
"postal": forms.TextInput(attrs={"class": "form-control"}),
|
|
"city": forms.TextInput(attrs={"class": "form-control"}),
|
|
"phone": forms.TextInput(attrs={"class": "form-control"}),
|
|
"gsm": forms.TextInput(attrs={"class": "form-control"}),
|
|
"email": forms.EmailInput(attrs={"class": "form-control"}),
|
|
"gsm_main_responsible": forms.TextInput(attrs={"class": "form-control"}),
|
|
"email_main_responsible": forms.EmailInput(attrs={"class": "form-control"}),
|
|
"gsm_second_responsible": forms.TextInput(attrs={"class": "form-control"}),
|
|
"email_second_responsible": forms.EmailInput(
|
|
attrs={"class": "form-control"}
|
|
),
|
|
# "is_active": forms.CheckboxInput(
|
|
# attrs={
|
|
# "class": "bootstrap-switch mt-0",
|
|
# "data-on-label": "<i class='tim-icons icon-check-2 text-success'></i>",
|
|
# "data-off-label": "<i class='tim-icons icon-simple-remove text-danger'></i>",
|
|
# }
|
|
# ),
|
|
"orientation": forms.Select(attrs={"class": "form-control"}),
|
|
"picture": forms.Select(attrs={"class": "form-control"}),
|
|
"content": forms.Textarea(
|
|
attrs={
|
|
"class": "form-control",
|
|
"placeholder": "Informations about the gymnast.",
|
|
}
|
|
),
|
|
}
|
|
|
|
|
|
class GymnastHasRoutineForm(forms.ModelForm):
|
|
"""
|
|
"""
|
|
|
|
class Meta:
|
|
model = GymnastHasRoutine
|
|
fields = ("gymnast", "routine", "routine_type", "datebegin", "dateend")
|
|
widgets = {
|
|
"gymnast": forms.HiddenInput(),
|
|
"routine": forms.HiddenInput(),
|
|
"routine_type": forms.Select(attrs={"class": "form-control"}),
|
|
"datebegin": forms.DateInput(attrs={"class": "form-control datepicker",}),
|
|
"dateend": forms.DateInput(attrs={"class": "form-control datepicker",}),
|
|
}
|
|
|
|
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",
|
|
}
|
|
)
|
|
)
|