1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-06-21 01:58:23 +02:00

Syntheses must not exceed 2 pages

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello
2023-05-20 17:09:32 +02:00
parent 3333add7e0
commit 20daecf619
2 changed files with 9 additions and 1 deletions

View File

@ -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):