From 20daecf619ad16cc55e0d76199679639b190d4a2 Mon Sep 17 00:00:00 2001 From: Emmy D'Anello Date: Sat, 20 May 2023 17:09:32 +0200 Subject: [PATCH] Syntheses must not exceed 2 pages Signed-off-by: Emmy D'Anello --- locale/fr/LC_MESSAGES/django.po | 6 +++++- participation/forms.py | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index 116aad8..dfc70b8 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: TFJM\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-05-20 11:44+0200\n" +"POT-Creation-Date: 2023-05-20 17:09+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Emmy D'Anello \n" "Language-Team: LANGUAGE \n" @@ -564,6 +564,10 @@ msgstr "" msgid "This defender did not work on this problem." msgstr "Ce⋅tte défenseur⋅se ne travaille pas sur ce problème." +#: participation/forms.py:357 +msgid "The PDF file must not have more than 2 pages." +msgstr "Le fichier PDF ne doit pas avoir plus de 2 pages." + #: participation/models.py:33 participation/models.py:136 #: participation/tables.py:17 participation/tables.py:33 msgid "name" diff --git a/participation/forms.py b/participation/forms.py index 7e98462..3887d56 100644 --- a/participation/forms.py +++ b/participation/forms.py @@ -351,6 +351,10 @@ class SynthesisForm(forms.ModelForm): raise ValidationError(_("The uploaded file size must be under 2 Mo.")) if file.content_type != "application/pdf": raise ValidationError(_("The uploaded file must be a PDF file.")) + pdf_reader = PdfReader(file) + pages = len(pdf_reader.pages) + if pages > 2: + raise ValidationError(_("The PDF file must not have more than 2 pages.")) return self.cleaned_data["file"] def save(self, commit=True):