diff --git a/app/models/but_validations.py b/app/models/but_validations.py index 7213af3c5..68b44e6be 100644 --- a/app/models/but_validations.py +++ b/app/models/but_validations.py @@ -324,7 +324,7 @@ def dict_decision_jury(etud: Identite, formsemestre: FormSemestre) -> dict: decisions["decision_rcue"] = [v.to_dict_bul() for v in validations_rcues] decisions["descr_decisions_rcue"] = ", ".join( [ - f"""{dec_rcue["niveau"]["competence"]["titre"]} {dec_rcue["niveau"]["ordre"]}: {dec_rcue["code"]}""" + f"""{dec_rcue["niveau"]["competence"]["titre"]} {dec_rcue["niveau"]["ordre"]}: {dec_rcue["code"]}""" for dec_rcue in decisions["decision_rcue"] ] ) diff --git a/app/scodoc/sco_bulletins_pdf.py b/app/scodoc/sco_bulletins_pdf.py index 3d91beb78..fbf9bd3fe 100644 --- a/app/scodoc/sco_bulletins_pdf.py +++ b/app/scodoc/sco_bulletins_pdf.py @@ -140,6 +140,15 @@ def process_field(field, cdict, style, suppress_empty_pars=False, format="pdf"): text = (field or "") % scu.WrapDict( cdict ) # note that None values are mapped to empty strings + except KeyError as exc: + log( + f"""process_field: KeyError on field={field!r} + values={pprint.pformat(cdict)} + """ + ) + if len(exc.args) > 0: + missing_field = exc.args[0] + text = f"""format invalide: champs {missing_field} inexistant !""" except: # pylint: disable=bare-except log( f"""process_field: invalid format. field={field!r} @@ -148,7 +157,6 @@ def process_field(field, cdict, style, suppress_empty_pars=False, format="pdf"): ) # ne sera pas visible si lien vers pdf: scu.flash_once(f"Attention: format PDF invalide (champs {field}") - raise ValueError text = ( "format invalide !" + traceback.format_exc() diff --git a/app/scodoc/sco_pvpdf.py b/app/scodoc/sco_pvpdf.py index ebfaefcf6..ac067339a 100644 --- a/app/scodoc/sco_pvpdf.py +++ b/app/scodoc/sco_pvpdf.py @@ -34,7 +34,7 @@ from PIL import Image as PILImage import reportlab from reportlab.lib.units import cm, mm -from reportlab.lib.enums import TA_RIGHT, TA_JUSTIFY +from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_JUSTIFY from reportlab.platypus import Paragraph, Spacer, Frame, PageBreak from reportlab.platypus import Table, TableStyle, Image from reportlab.platypus.doctemplate import PageTemplate, BaseDocTemplate @@ -339,8 +339,11 @@ def _simulate_br(paragraph_txt: str, para="") -> str: """Reportlab bug turnaround (could be removed in a future version). p is a string with Reportlab intra-paragraph XML tags. Replaces
(currently ignored by Reportlab) by
+ Also replaces
by
""" - return ("
" + para).join(re.split(r"<.*?br.*?/>", paragraph_txt)) + return ("
" + para).join( + re.split(r"<.*?br.*?/>", paragraph_txt.replace("
", "
")) + ) def _make_signature_image(signature, leftindent, formsemestre_id) -> Table: @@ -480,7 +483,7 @@ def pdf_lettre_individuelle(sem, decision, etud: Identite, params, signature=Non style.fontSize = 14 style.fontName = sco_preferences.get_preference("PV_FONTNAME", formsemestre_id) style.leading = 18 - style.alignment = TA_JUSTIFY + style.alignment = TA_LEFT params["semestre_id"] = formsemestre.semestre_id params["decision_sem_descr"] = decision["decision_sem_descr"]