1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2024-11-30 10:53:01 +00:00
plateforme-tfjm2/apps/member/forms.py
2020-09-19 21:07:04 +02:00

84 lines
2.4 KiB
Python

from bootstrap_datepicker_plus import DatePickerInput
from django.contrib.auth.forms import UserCreationForm
from django import forms
from django.utils.translation import gettext_lazy as _
from .models import TFJMUser
class SignUpForm(UserCreationForm):
"""
Coaches and participants register on the website through this form.
TODO: Check if this form works, render it better
"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["first_name"].required = True
self.fields["last_name"].required = True
self.fields["role"].choices = [
('', _("Choose a role...")),
('3participant', _("Participant")),
('2coach', _("Coach")),
]
class Meta:
model = TFJMUser
fields = (
'role',
'email',
'first_name',
'last_name',
'birth_date',
'gender',
'address',
'postal_code',
'city',
'country',
'phone_number',
'school',
'student_class',
'responsible_name',
'responsible_phone',
'responsible_email',
'description',
)
widgets = {
"birth_date": DatePickerInput(),
}
class TFJMUserForm(forms.ModelForm):
"""
Form to update our own information when we are participant.
"""
class Meta:
model = TFJMUser
fields = ('last_name', 'first_name', 'email', 'phone_number', 'gender', 'birth_date', 'address', 'postal_code',
'city', 'country', 'school', 'student_class', 'responsible_name', 'responsible_phone',
'responsible_email',)
widgets = {
"birth_date": DatePickerInput(),
}
class CoachUserForm(forms.ModelForm):
"""
Form to update our own information when we are coach.
"""
class Meta:
model = TFJMUser
fields = ('last_name', 'first_name', 'email', 'phone_number', 'gender', 'birth_date', 'address', 'postal_code',
'city', 'country', 'description',)
widgets = {
"birth_date": DatePickerInput(),
}
class AdminUserForm(forms.ModelForm):
"""
Form to update our own information when we are organizer or admin.
"""
class Meta:
model = TFJMUser
fields = ('last_name', 'first_name', 'email', 'phone_number', 'description',)