PdfFileReader is deprecated, replace by PdfReader

This commit is contained in:
Emmy D'Anello 2023-03-29 18:34:55 +02:00
parent ce25341496
commit fc6e2593b4
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
1 changed files with 2 additions and 2 deletions

View File

@ -11,7 +11,7 @@ from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
from django.core.validators import FileExtensionValidator
from django.utils.translation import gettext_lazy as _
from pypdf import PdfFileReader
from pypdf import PdfReader
from .models import Note, Participation, Passage, Pool, Solution, Synthesis, Team, Tournament
@ -151,7 +151,7 @@ class SolutionForm(forms.ModelForm):
raise ValidationError(_("The uploaded file size must be under 5 Mo."))
if file.content_type != "application/pdf":
raise ValidationError(_("The uploaded file must be a PDF file."))
pdf_reader = PdfFileReader(file)
pdf_reader = PdfReader(file)
pages = len(pdf_reader.pages)
if pages > 30:
raise ValidationError(_("The PDF file must not have more than 30 pages."))