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

Don't send too large files

This commit is contained in:
Yohann D'ANELLO
2020-12-22 20:20:35 +01:00
parent 8f09ca5553
commit 996d00c7f0
2 changed files with 44 additions and 38 deletions

View File

@ -72,6 +72,8 @@ class PhotoAuthorizationForm(forms.ModelForm):
Form to send a photo authorization.
"""
def clean_photo_authorization(self):
if "photo_authorization" not in self.files:
raise ValidationError(_("The uploaded file size must be under 2 Mo."))
file = self.files["photo_authorization"]
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."))