From a70e6236d423bdb9b7bf664d79d5d2348878610e Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 7 Dec 2023 23:07:11 +0100 Subject: [PATCH] =?UTF-8?q?Am=C3=A9liore=20traitement=20erreurs=20dans=20c?= =?UTF-8?q?hamp=20PV=20intro=20PDF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/__init__.py | 5 +++-- app/scodoc/sco_pv_pdf.py | 32 ++++++++++++++++++-------------- sco_version.py | 2 +- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 7998f19a..0b7695a2 100755 --- a/app/__init__.py +++ b/app/__init__.py @@ -86,8 +86,9 @@ def handle_invalid_csrf(exc): return render_template("error_csrf.j2", exc=exc), 404 -def handle_pdf_format_error(exc): - return "ay ay ay" +# def handle_pdf_format_error(exc): +# return "ay ay ay" +handle_pdf_format_error = handle_sco_value_error def internal_server_error(exc): diff --git a/app/scodoc/sco_pv_pdf.py b/app/scodoc/sco_pv_pdf.py index 551888fe..797582bd 100644 --- a/app/scodoc/sco_pv_pdf.py +++ b/app/scodoc/sco_pv_pdf.py @@ -46,6 +46,7 @@ from reportlab.lib.colors import Color from app.models import FormSemestre 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_pdf from app.scodoc import sco_preferences @@ -217,20 +218,23 @@ def _pvjury_pdf_type( f"""Jury tenu le {date_jury}""", style ) - objects += sco_pdf.make_paras( - "" - + (sco_preferences.get_preference("PV_INTRO", formsemestre.id) or "") - % { - "Decnum": numero_arrete, - "VDICode": code_vdi, - "UnivName": sco_preferences.get_preference("UnivName", formsemestre.id), - "Type": titre_jury, - "Date": date_commission, # deprecated - "date_commission": date_commission, - } - + "", - style_bullet, - ) + try: + objects += sco_pdf.make_paras( + "" + + (sco_preferences.get_preference("PV_INTRO", formsemestre.id) or "") + % { + "Decnum": numero_arrete, + "VDICode": code_vdi, + "UnivName": sco_preferences.get_preference("UnivName", formsemestre.id), + "Type": titre_jury, + "Date": date_commission, # deprecated + "date_commission": date_commission, + } + + "", + style_bullet, + ) + except KeyError as exc: + raise ScoPDFFormatError(msg=f"balise inconnue: {exc.args[0]}") from exc objects += sco_pdf.make_paras( """Le jury propose les décisions suivantes :""", style diff --git a/sco_version.py b/sco_version.py index 772a6805..678af334 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.6.65" +SCOVERSION = "9.6.66" SCONAME = "ScoDoc"