Message erreur si signature pdf invalide

This commit is contained in:
Emmanuel Viennet 2022-09-06 13:47:37 +02:00
parent 2069c75e9f
commit 6082f1dbd9
2 changed files with 17 additions and 7 deletions

View File

@ -31,6 +31,7 @@ import io
import re import re
from PIL import Image as PILImage from PIL import Image as PILImage
from PIL import UnidentifiedImageError
import reportlab import reportlab
from reportlab.lib.units import cm, mm from reportlab.lib.units import cm, mm
@ -51,6 +52,7 @@ from app.scodoc import sco_codes_parcours
from app.scodoc import sco_etud from app.scodoc import sco_etud
from app.scodoc import sco_pdf from app.scodoc import sco_pdf
from app.scodoc import sco_preferences from app.scodoc import sco_preferences
from app.scodoc.sco_exceptions import ScoValueError
from app.scodoc.sco_logos import find_logo from app.scodoc.sco_logos import find_logo
from app.scodoc.sco_cursus_dut import SituationEtudCursus from app.scodoc.sco_cursus_dut import SituationEtudCursus
from app.scodoc.sco_pdf import SU from app.scodoc.sco_pdf import SU
@ -416,9 +418,14 @@ def pdf_lettres_individuelles(
etud: Identite = Identite.query.get(decision["identite"]["etudid"]) etud: Identite = Identite.query.get(decision["identite"]["etudid"])
params["nomEtud"] = etud.nomprenom params["nomEtud"] = etud.nomprenom
bookmarks[npages + 1] = scu.suppress_accents(etud.nomprenom) bookmarks[npages + 1] = scu.suppress_accents(etud.nomprenom)
objects += pdf_lettre_individuelle( try:
dpv["formsemestre"], decision, etud, params, signature objects += pdf_lettre_individuelle(
) dpv["formsemestre"], decision, etud, params, signature
)
except UnidentifiedImageError as exc:
raise ScoValueError(
"Fichier image (signature ou logo ?) invalide !"
) from exc
objects.append(PageBreak()) objects.append(PageBreak())
npages += 1 npages += 1
if npages == 0: if npages == 0:
@ -606,9 +613,12 @@ def pdf_lettre_individuelle(sem, decision, etud: Identite, params, signature=Non
) )
if signature: if signature:
objects.append( try:
_make_signature_image(signature, params["htab1"], formsemestre_id) objects.append(
) _make_signature_image(signature, params["htab1"], formsemestre_id)
)
except UnidentifiedImageError as exc:
raise ScoValueError("Image signature invalide !") from exc
return objects return objects

View File

@ -1,7 +1,7 @@
# -*- mode: python -*- # -*- mode: python -*-
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
SCOVERSION = "9.3.33" SCOVERSION = "9.3.34"
SCONAME = "ScoDoc" SCONAME = "ScoDoc"