1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-07-03 00:02:50 +02:00

Upload all authorizations

This commit is contained in:
Yohann D'ANELLO
2020-12-29 16:14:56 +01:00
parent 72753edf64
commit e3a32a41f9
10 changed files with 252 additions and 68 deletions

View File

@ -1,7 +1,6 @@
# Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later
from address.forms import AddressField
from address.widgets import AddressWidget
from django import forms
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
@ -69,7 +68,8 @@ class StudentRegistrationForm(forms.ModelForm):
class Meta:
model = StudentRegistration
fields = ('team', 'student_class', 'birth_date', 'address', 'phone_number',
'school', 'give_contact_to_animath', 'email_confirmed',)
'school', 'responsible_name', 'responsible_phone', 'responsible_email',
'give_contact_to_animath', 'email_confirmed',)
class PhotoAuthorizationForm(forms.ModelForm):
@ -94,6 +94,50 @@ class PhotoAuthorizationForm(forms.ModelForm):
fields = ('photo_authorization',)
class HealthSheetForm(forms.ModelForm):
"""
Form to send a health sheet.
"""
def clean_health_sheet(self):
if "health_sheet" in self.files:
file = self.files["health_sheet"]
if file.size > 2e6:
raise ValidationError(_("The uploaded file size must be under 2 Mo."))
if file.content_type not in ["application/pdf", "image/png", "image/jpeg"]:
raise ValidationError(_("The uploaded file must be a PDF, PNG of JPEG file."))
return self.cleaned_data["health_sheet"]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["health_sheet"].widget = FileInput()
class Meta:
model = StudentRegistration
fields = ('health_sheet',)
class ParentalAuthorizationForm(forms.ModelForm):
"""
Form to send a parental authorization.
"""
def clean_parental_authorization(self):
if "parental_authorization" in self.files:
file = self.files["parental_authorization"]
if file.size > 2e6:
raise ValidationError(_("The uploaded file size must be under 2 Mo."))
if file.content_type not in ["application/pdf", "image/png", "image/jpeg"]:
raise ValidationError(_("The uploaded file must be a PDF, PNG of JPEG file."))
return self.cleaned_data["parental_authorization"]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["parental_authorization"].widget = FileInput()
class Meta:
model = StudentRegistration
fields = ('parental_authorization',)
class CoachRegistrationForm(forms.ModelForm):
"""
A coach can tell its professional activity.