Améliore traitement erreurs dans champ PV intro PDF

This commit is contained in:
Emmanuel Viennet 2023-12-07 23:07:11 +01:00
parent a5c927db75
commit a70e6236d4
3 changed files with 22 additions and 17 deletions

View File

@ -86,8 +86,9 @@ def handle_invalid_csrf(exc):
return render_template("error_csrf.j2", exc=exc), 404 return render_template("error_csrf.j2", exc=exc), 404
def handle_pdf_format_error(exc): # def handle_pdf_format_error(exc):
return "ay ay ay" # return "ay ay ay"
handle_pdf_format_error = handle_sco_value_error
def internal_server_error(exc): def internal_server_error(exc):

View File

@ -46,6 +46,7 @@ from reportlab.lib.colors import Color
from app.models import FormSemestre from app.models import FormSemestre
from app.scodoc import codes_cursus from app.scodoc import codes_cursus
from app.scodoc.sco_exceptions import ScoPDFFormatError
from app.scodoc import sco_pv_dict from app.scodoc import sco_pv_dict
from app.scodoc import sco_pdf from app.scodoc import sco_pdf
from app.scodoc import sco_preferences from app.scodoc import sco_preferences
@ -217,20 +218,23 @@ def _pvjury_pdf_type(
f"""<para align="center">Jury tenu le {date_jury}</para>""", style f"""<para align="center">Jury tenu le {date_jury}</para>""", style
) )
objects += sco_pdf.make_paras( try:
"<para>" objects += sco_pdf.make_paras(
+ (sco_preferences.get_preference("PV_INTRO", formsemestre.id) or "") "<para>"
% { + (sco_preferences.get_preference("PV_INTRO", formsemestre.id) or "")
"Decnum": numero_arrete, % {
"VDICode": code_vdi, "Decnum": numero_arrete,
"UnivName": sco_preferences.get_preference("UnivName", formsemestre.id), "VDICode": code_vdi,
"Type": titre_jury, "UnivName": sco_preferences.get_preference("UnivName", formsemestre.id),
"Date": date_commission, # deprecated "Type": titre_jury,
"date_commission": date_commission, "Date": date_commission, # deprecated
} "date_commission": date_commission,
+ "</para>", }
style_bullet, + "</para>",
) style_bullet,
)
except KeyError as exc:
raise ScoPDFFormatError(msg=f"balise inconnue: {exc.args[0]}") from exc
objects += sco_pdf.make_paras( objects += sco_pdf.make_paras(
"""<para>Le jury propose les décisions suivantes :</para>""", style """<para>Le jury propose les décisions suivantes :</para>""", style

View File

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