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

Add vaccine sheet field, closes #18

This commit is contained in:
Emmy D'Anello
2023-02-20 00:38:57 +01:00
parent fae4ee7105
commit 0f2c44331c
12 changed files with 337 additions and 148 deletions

View File

@ -146,6 +146,28 @@ class HealthSheetForm(forms.ModelForm):
fields = ('health_sheet',)
class VaccineSheetForm(forms.ModelForm):
"""
Form to send a vaccine sheet.
"""
def clean_vaccine_sheet(self):
if "vaccine_sheet" in self.files:
file = self.files["vaccine_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["vaccine_sheet"]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["vaccine_sheet"].widget = FileInput()
class Meta:
model = StudentRegistration
fields = ('vaccine_sheet',)
class ParentalAuthorizationForm(forms.ModelForm):
"""
Form to send a parental authorization.