Ultron/ultron/people/forms.py

105 lines
3.2 KiB
Python

"""Formulaires de gestion des données entrantes pour les gymnastes et accidents."""
from django import forms
from django.contrib.auth import get_user_model
from .models import Gymnast
User = get_user_model()
class GymnastForm(forms.ModelForm):
class Meta:
model = Gymnast
fields = (
"last_name",
"first_name",
"birthdate",
"gender",
"is_active",
"orientation",
"year_of_practice",
"club",
"email_trainer",
"trainings_by_week",
"hours_by_week",
"informations",
)
widgets = {
"last_name": forms.TextInput(
attrs={"class": "form-control", "placeholder": "Lastname"}
),
"first_name": forms.TextInput(
attrs={"class": "form-control", "placeholder": "Firstname"}
),
"birthdate": forms.DateInput(attrs={"class": "form-control datepicker"}),
"gender": forms.Select(attrs={"class": "form-control selectpicker"}),
"club": forms.HiddenInput(),
"email_trainer": forms.TextInput(
attrs={
"class": "form-control",
"placeholder": "trainer_email@email.com",
}
),
"trainings_by_week": forms.TextInput(
attrs={"class": "form-control", "placeholder": "5"}
),
"hours_by_week": forms.TextInput(
attrs={"class": "form-control", "placeholder": "11,5"}
),
"is_active": forms.CheckboxInput(
attrs={"class": "form-control form-check-input ml-0 mt-0"}
),
"orientation": forms.Select(attrs={"class": "form-control selectpicker"}),
"year_of_practice": forms.TextInput(
attrs={"class": "form-control", "placeholder": "3"}
),
"informations": forms.Textarea(
attrs={
"class": "form-control",
"placeholder": "Informations about gymnast: fear, lost skill syndrom, …", # pylint: disable=line-too-long
}
),
}
last_name = forms.CharField(
widget=forms.TextInput(
attrs={"class": "form-control", "placeholder": "Lastname"}
)
)
first_name = forms.CharField(
widget=forms.TextInput(
attrs={"class": "form-control", "placeholder": "Firstname"}
)
)
email = forms.EmailField(
required=False,
widget=forms.TextInput(
attrs={"class": "form-control", "placeholder": "my_email@email.com"}
),
)
club_related = forms.CharField(
required=False,
widget=forms.TextInput(
attrs={
"class": "form-control",
"placeholder": "Searching club…",
"data-ref": "#id_club",
}
),
)
class UserForm(forms.ModelForm):
class Meta:
model = User
fields = (
"last_name",
"first_name",
"email",
"is_active",
"username",
)