mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-07-04 19:04:03 +02:00
Add a lot of comments
This commit is contained in:
@ -9,6 +9,11 @@ from .models import AdminRegistration, CoachRegistration, StudentRegistration
|
||||
|
||||
|
||||
class SignupForm(UserCreationForm):
|
||||
"""
|
||||
Signup form to registers participants and coaches
|
||||
They can choose the role at the registration.
|
||||
"""
|
||||
|
||||
role = forms.ChoiceField(
|
||||
label=lambda: _("role").capitalize(),
|
||||
choices=lambda: [
|
||||
@ -29,6 +34,10 @@ class SignupForm(UserCreationForm):
|
||||
|
||||
|
||||
class UserForm(forms.ModelForm):
|
||||
"""
|
||||
Replace the default user form to require the first name, last name and the email.
|
||||
The username is always equal to the email.
|
||||
"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields["first_name"].required = True
|
||||
@ -41,12 +50,18 @@ class UserForm(forms.ModelForm):
|
||||
|
||||
|
||||
class StudentRegistrationForm(forms.ModelForm):
|
||||
"""
|
||||
A student can update its class, its school and if it allows Animath to contact him/her later.
|
||||
"""
|
||||
class Meta:
|
||||
model = StudentRegistration
|
||||
fields = ('student_class', 'school', 'give_contact_to_animath',)
|
||||
|
||||
|
||||
class PhotoAuthorizationForm(forms.ModelForm):
|
||||
"""
|
||||
Form to send a photo authorization.
|
||||
"""
|
||||
def clean_photo_authorization(self):
|
||||
file = self.files["photo_authorization"]
|
||||
if file.content_type not in ["application/pdf", "image/png", "image/jpeg"]:
|
||||
@ -63,12 +78,18 @@ class PhotoAuthorizationForm(forms.ModelForm):
|
||||
|
||||
|
||||
class CoachRegistrationForm(forms.ModelForm):
|
||||
"""
|
||||
A coach can tell its professional activity.
|
||||
"""
|
||||
class Meta:
|
||||
model = CoachRegistration
|
||||
fields = ('professional_activity', 'give_contact_to_animath',)
|
||||
|
||||
|
||||
class AdminRegistrationForm(forms.ModelForm):
|
||||
"""
|
||||
Admins can tell everything they want.
|
||||
"""
|
||||
class Meta:
|
||||
model = AdminRegistration
|
||||
fields = ('role', 'give_contact_to_animath',)
|
||||
|
Reference in New Issue
Block a user