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
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
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. Form to send a photo authorization.
""" """
def clean_photo_authorization(self): 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"] file = self.files["photo_authorization"]
if file.content_type not in ["application/pdf", "image/png", "image/jpeg"]: 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.")) raise ValidationError(_("The uploaded file must be a PDF, PNG of JPEG file."))

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Corres2math\n" "Project-Id-Version: Corres2math\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-12-11 16:09+0100\n" "POT-Creation-Date: 2020-12-22 19:37+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Yohann D'ANELLO <yohann.danello@animath.fr>\n" "Last-Translator: Yohann D'ANELLO <yohann.danello@animath.fr>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -503,7 +503,7 @@ msgstr "Définir l'équipe qui recevra votre vidéo"
#: apps/participation/templates/participation/participation_detail.html:181 #: apps/participation/templates/participation/participation_detail.html:181
#: apps/participation/templates/participation/participation_detail.html:233 #: apps/participation/templates/participation/participation_detail.html:233
#: apps/participation/views.py:499 #: apps/participation/views.py:500
msgid "Upload video" msgid "Upload video"
msgstr "Envoyer la vidéo" msgstr "Envoyer la vidéo"
@ -538,7 +538,7 @@ msgid "Update question"
msgstr "Modifier la question" msgstr "Modifier la question"
#: apps/participation/templates/participation/participation_detail.html:217 #: apps/participation/templates/participation/participation_detail.html:217
#: apps/participation/views.py:475 #: apps/participation/views.py:476
msgid "Delete question" msgid "Delete question"
msgstr "Supprimer la question" msgstr "Supprimer la question"
@ -548,7 +548,7 @@ msgid "Display synthesis"
msgstr "Afficher la synthèse" msgstr "Afficher la synthèse"
#: apps/participation/templates/participation/phase_list.html:10 #: apps/participation/templates/participation/phase_list.html:10
#: apps/participation/views.py:518 corres2math/templates/base.html:68 #: apps/participation/views.py:519 corres2math/templates/base.html:68
#: corres2math/templates/base.html:70 corres2math/templates/base.html:226 #: corres2math/templates/base.html:70 corres2math/templates/base.html:226
msgid "Calendar" msgid "Calendar"
msgstr "Calendrier" msgstr "Calendrier"
@ -661,7 +661,7 @@ msgid "Update team"
msgstr "Modifier l'équipe" msgstr "Modifier l'équipe"
#: apps/participation/templates/participation/team_detail.html:127 #: apps/participation/templates/participation/team_detail.html:127
#: apps/participation/views.py:328 #: apps/participation/views.py:329
msgid "Leave team" msgid "Leave team"
msgstr "Quitter l'équipe" msgstr "Quitter l'équipe"
@ -674,49 +674,49 @@ msgstr "Êtes-vous sûr·e de vouloir quitter cette équipe ?"
msgid "All teams" msgid "All teams"
msgstr "Toutes les équipes" msgstr "Toutes les équipes"
#: apps/participation/views.py:36 corres2math/templates/base.html:84 #: apps/participation/views.py:37 corres2math/templates/base.html:84
#: corres2math/templates/base.html:241 #: corres2math/templates/base.html:241
msgid "Create team" msgid "Create team"
msgstr "Créer une équipe" msgstr "Créer une équipe"
#: apps/participation/views.py:43 apps/participation/views.py:89 #: apps/participation/views.py:44 apps/participation/views.py:90
msgid "You don't participate, so you can't create a team." msgid "You don't participate, so you can't create a team."
msgstr "Vous ne participez pas, vous ne pouvez pas créer d'équipe." msgstr "Vous ne participez pas, vous ne pouvez pas créer d'équipe."
#: apps/participation/views.py:45 apps/participation/views.py:91 #: apps/participation/views.py:46 apps/participation/views.py:92
msgid "You are already in a team." msgid "You are already in a team."
msgstr "Vous êtes déjà dans une équipe." msgstr "Vous êtes déjà dans une équipe."
#: apps/participation/views.py:82 corres2math/templates/base.html:89 #: apps/participation/views.py:83 corres2math/templates/base.html:89
#: corres2math/templates/base.html:236 #: corres2math/templates/base.html:236
msgid "Join team" msgid "Join team"
msgstr "Rejoindre une équipe" msgstr "Rejoindre une équipe"
#: apps/participation/views.py:142 apps/participation/views.py:334 #: apps/participation/views.py:143 apps/participation/views.py:335
#: apps/participation/views.py:367 #: apps/participation/views.py:368
msgid "You are not in a team." msgid "You are not in a team."
msgstr "Vous n'êtes pas dans une équipe." msgstr "Vous n'êtes pas dans une équipe."
#: apps/participation/views.py:143 apps/participation/views.py:368 #: apps/participation/views.py:144 apps/participation/views.py:369
msgid "You don't participate, so you don't have any team." msgid "You don't participate, so you don't have any team."
msgstr "Vous ne participez pas, vous n'avez donc pas d'équipe." msgstr "Vous ne participez pas, vous n'avez donc pas d'équipe."
#: apps/participation/views.py:165 #: apps/participation/views.py:166
#, python-brace-format #, python-brace-format
msgid "Detail of team {trigram}" msgid "Detail of team {trigram}"
msgstr "Détails de l'équipe {trigram}" msgstr "Détails de l'équipe {trigram}"
#: apps/participation/views.py:197 #: apps/participation/views.py:198
msgid "You don't participate, so you can't request the validation of the team." msgid "You don't participate, so you can't request the validation of the team."
msgstr "" msgstr ""
"Vous ne participez pas, vous ne pouvez pas demander la validation de " "Vous ne participez pas, vous ne pouvez pas demander la validation de "
"l'équipe." "l'équipe."
#: apps/participation/views.py:200 #: apps/participation/views.py:201
msgid "The validation of the team is already done or pending." msgid "The validation of the team is already done or pending."
msgstr "La validation de l'équipe est déjà faite ou en cours." msgstr "La validation de l'équipe est déjà faite ou en cours."
#: apps/participation/views.py:203 #: apps/participation/views.py:204
msgid "" msgid ""
"The team can't be validated: missing email address confirmations, photo " "The team can't be validated: missing email address confirmations, photo "
"authorizations, people or the chosen problem is not set." "authorizations, people or the chosen problem is not set."
@ -725,51 +725,51 @@ msgstr ""
"d'adresse e-mail, soit une autorisation parentale, soit des personnes soit " "d'adresse e-mail, soit une autorisation parentale, soit des personnes soit "
"le problème n'a pas été choisi." "le problème n'a pas été choisi."
#: apps/participation/views.py:222 #: apps/participation/views.py:223
msgid "You are not an administrator." msgid "You are not an administrator."
msgstr "Vous n'êtes pas administrateur." msgstr "Vous n'êtes pas administrateur."
#: apps/participation/views.py:225 #: apps/participation/views.py:226
msgid "This team has no pending validation." msgid "This team has no pending validation."
msgstr "L'équipe n'a pas de validation en attente." msgstr "L'équipe n'a pas de validation en attente."
#: apps/participation/views.py:249 #: apps/participation/views.py:250
msgid "You must specify if you validate the registration or not." msgid "You must specify if you validate the registration or not."
msgstr "Vous devez spécifier si vous validez l'inscription ou non." msgstr "Vous devez spécifier si vous validez l'inscription ou non."
#: apps/participation/views.py:277 #: apps/participation/views.py:278
#, python-brace-format #, python-brace-format
msgid "Update team {trigram}" msgid "Update team {trigram}"
msgstr "Mise à jour de l'équipe {trigram}" msgstr "Mise à jour de l'équipe {trigram}"
#: apps/participation/views.py:314 apps/registration/views.py:284 #: apps/participation/views.py:315 apps/registration/views.py:283
#, python-brace-format #, python-brace-format
msgid "Photo authorization of {student}.{ext}" msgid "Photo authorization of {student}.{ext}"
msgstr "Autorisation de droit à l'image de {student}.{ext}" msgstr "Autorisation de droit à l'image de {student}.{ext}"
#: apps/participation/views.py:318 #: apps/participation/views.py:319
#, python-brace-format #, python-brace-format
msgid "Photo authorizations of team {trigram}.zip" msgid "Photo authorizations of team {trigram}.zip"
msgstr "Autorisations de droit à l'image de l'équipe {trigram}.zip" msgstr "Autorisations de droit à l'image de l'équipe {trigram}.zip"
#: apps/participation/views.py:336 #: apps/participation/views.py:337
msgid "The team is already validated or the validation is pending." msgid "The team is already validated or the validation is pending."
msgstr "La validation de l'équipe est déjà faite ou en cours." msgstr "La validation de l'équipe est déjà faite ou en cours."
#: apps/participation/views.py:380 #: apps/participation/views.py:381
msgid "The team is not validated yet." msgid "The team is not validated yet."
msgstr "L'équipe n'est pas encore validée." msgstr "L'équipe n'est pas encore validée."
#: apps/participation/views.py:390 #: apps/participation/views.py:391
#, python-brace-format #, python-brace-format
msgid "Participation of team {trigram}" msgid "Participation of team {trigram}"
msgstr "Participation de l'équipe {trigram}" msgstr "Participation de l'équipe {trigram}"
#: apps/participation/views.py:427 #: apps/participation/views.py:428
msgid "Create question" msgid "Create question"
msgstr "Créer une question" msgstr "Créer une question"
#: apps/participation/views.py:527 #: apps/participation/views.py:528
msgid "Calendar update" msgid "Calendar update"
msgstr "Mise à jour du calendrier" msgstr "Mise à jour du calendrier"
@ -789,7 +789,11 @@ msgstr "encadrant"
msgid "This email address is already used." msgid "This email address is already used."
msgstr "Cette adresse e-mail est déjà utilisée." msgstr "Cette adresse e-mail est déjà utilisée."
#: apps/registration/forms.py:77 #: apps/registration/forms.py:76
msgid "The uploaded file size must be under 2 Mo."
msgstr "Le fichier envoyé doit peser moins de 2 Mo."
#: apps/registration/forms.py:79
msgid "The uploaded file must be a PDF, PNG of JPEG file." msgid "The uploaded file must be a PDF, PNG of JPEG file."
msgstr "Le fichier envoyé doit être au format PDF, PNG ou JPEG." msgstr "Le fichier envoyé doit être au format PDF, PNG ou JPEG."
@ -1032,7 +1036,7 @@ msgstr "Réinitialiser mon mot de passe"
#: apps/registration/templates/registration/signup.html:5 #: apps/registration/templates/registration/signup.html:5
#: apps/registration/templates/registration/signup.html:8 #: apps/registration/templates/registration/signup.html:8
#: apps/registration/templates/registration/signup.html:20 #: apps/registration/templates/registration/signup.html:20
#: apps/registration/views.py:33 #: apps/registration/views.py:32
msgid "Sign up" msgid "Sign up"
msgstr "Inscription" msgstr "Inscription"
@ -1109,40 +1113,40 @@ msgid "Update user"
msgstr "Modifier l'utilisateur" msgstr "Modifier l'utilisateur"
#: apps/registration/templates/registration/user_detail.html:77 #: apps/registration/templates/registration/user_detail.html:77
#: apps/registration/views.py:247 #: apps/registration/views.py:246
msgid "Upload photo authorization" msgid "Upload photo authorization"
msgstr "Téléverser l'autorisation de droit à l'image" msgstr "Téléverser l'autorisation de droit à l'image"
#: apps/registration/views.py:41 #: apps/registration/views.py:40
msgid "You can't register now." msgid "You can't register now."
msgstr "Vous ne pouvez pas vous inscrire maintenant." msgstr "Vous ne pouvez pas vous inscrire maintenant."
#: apps/registration/views.py:85 #: apps/registration/views.py:84
msgid "Email validation" msgid "Email validation"
msgstr "Validation de l'adresse mail" msgstr "Validation de l'adresse mail"
#: apps/registration/views.py:87 #: apps/registration/views.py:86
msgid "Validate email" msgid "Validate email"
msgstr "Valider l'adresse mail" msgstr "Valider l'adresse mail"
#: apps/registration/views.py:126 #: apps/registration/views.py:125
msgid "Email validation unsuccessful" msgid "Email validation unsuccessful"
msgstr "Échec de la validation de l'adresse mail" msgstr "Échec de la validation de l'adresse mail"
#: apps/registration/views.py:137 #: apps/registration/views.py:136
msgid "Email validation email sent" msgid "Email validation email sent"
msgstr "Mail de confirmation de l'adresse mail envoyé" msgstr "Mail de confirmation de l'adresse mail envoyé"
#: apps/registration/views.py:145 #: apps/registration/views.py:144
msgid "Resend email validation link" msgid "Resend email validation link"
msgstr "Renvoyé le lien de validation de l'adresse mail" msgstr "Renvoyé le lien de validation de l'adresse mail"
#: apps/registration/views.py:181 #: apps/registration/views.py:180
#, python-brace-format #, python-brace-format
msgid "Detail of user {user}" msgid "Detail of user {user}"
msgstr "Détails de l'utilisateur {user}" msgstr "Détails de l'utilisateur {user}"
#: apps/registration/views.py:211 #: apps/registration/views.py:210
#, python-brace-format #, python-brace-format
msgid "Update user {user}" msgid "Update user {user}"
msgstr "Mise à jour de l'utilisateur {user}" msgstr "Mise à jour de l'utilisateur {user}"