2020-04-29 13:29:01 +00:00
|
|
|
from django.contrib.auth.forms import UserCreationForm
|
2020-05-04 18:21:53 +00:00
|
|
|
from django import forms
|
2020-04-29 13:29:01 +00:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
|
2020-05-11 12:08:19 +00:00
|
|
|
from .models import TFJMUser
|
2020-04-29 13:29:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
class SignUpForm(UserCreationForm):
|
2020-05-11 12:08:19 +00:00
|
|
|
"""
|
|
|
|
Coaches and participants register on the website through this form.
|
|
|
|
TODO: Check if this form works, render it better
|
|
|
|
"""
|
2020-04-29 13:29:01 +00:00
|
|
|
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...")),
|
2020-05-11 12:08:19 +00:00
|
|
|
('3participant', _("Participant")),
|
|
|
|
('2coach', _("Coach")),
|
2020-04-29 13:29:01 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
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',
|
|
|
|
)
|
2020-05-04 18:21:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TFJMUserForm(forms.ModelForm):
|
2020-05-11 12:08:19 +00:00
|
|
|
"""
|
|
|
|
Form to update our own information when we are participant.
|
|
|
|
"""
|
2020-05-04 18:21:53 +00:00
|
|
|
class Meta:
|
|
|
|
model = TFJMUser
|
2020-05-04 23:04:07 +00:00
|
|
|
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',)
|
|
|
|
|
|
|
|
|
|
|
|
class CoachUserForm(forms.ModelForm):
|
2020-05-11 12:08:19 +00:00
|
|
|
"""
|
|
|
|
Form to update our own information when we are coach.
|
|
|
|
"""
|
2020-05-04 23:04:07 +00:00
|
|
|
class Meta:
|
|
|
|
model = TFJMUser
|
|
|
|
fields = ('last_name', 'first_name', 'email', 'phone_number', 'gender', 'birth_date', 'address', 'postal_code',
|
|
|
|
'city', 'country', 'description',)
|
|
|
|
|
|
|
|
|
|
|
|
class AdminUserForm(forms.ModelForm):
|
2020-05-11 12:08:19 +00:00
|
|
|
"""
|
|
|
|
Form to update our own information when we are organizer or admin.
|
|
|
|
"""
|
2020-05-04 23:04:07 +00:00
|
|
|
class Meta:
|
|
|
|
model = TFJMUser
|
|
|
|
fields = ('last_name', 'first_name', 'email', 'phone_number', 'description',)
|