diff --git a/app/scodoc/gen_tables.py b/app/scodoc/gen_tables.py index 2ac3c3981..855545556 100644 --- a/app/scodoc/gen_tables.py +++ b/app/scodoc/gen_tables.py @@ -58,7 +58,7 @@ from app.scodoc import sco_utils as scu from app.scodoc import sco_excel from app.scodoc import sco_pdf from app.scodoc import sco_xml -from app.scodoc.sco_exceptions import ScoValueError +from app.scodoc.sco_exceptions import ScoPDFFormatError from app.scodoc.sco_pdf import SU from app import log @@ -551,7 +551,7 @@ class GenTable(object): [Paragraph(SU(str(x)), CellStyle) for x in line] for line in data_list ] except ValueError as exc: - raise ScoValueError(f"Erreur dans un format pdf:
{str(exc)}") from exc + raise ScoPDFFormatError(str(exc)) from exc pdf_style_list += self.pdf_table_style T = Table(Pt, repeatRows=1, colWidths=self.pdf_col_widths, style=pdf_style_list) diff --git a/app/scodoc/sco_exceptions.py b/app/scodoc/sco_exceptions.py index c563c93e6..d975766ef 100644 --- a/app/scodoc/sco_exceptions.py +++ b/app/scodoc/sco_exceptions.py @@ -60,6 +60,21 @@ class ScoFormatError(ScoValueError): pass +class ScoPDFFormatError(ScoValueError): + "erreur génération PDF (templates platypus, ...)" + + def __init__(self, msg, dest_url=None): + super().__init__( + f"""Erreur dans un format pdf: +

{msg}

+

Vérifiez les paramètres (polices de caractères, balisage) + dans les paramètres ou préférences. +

+ """, + dest_url=dest_url, + ) + + class ScoInvalidDept(ScoValueError): """departement invalide""" diff --git a/app/scodoc/sco_groups_view.py b/app/scodoc/sco_groups_view.py index 603627d14..df4c55e98 100644 --- a/app/scodoc/sco_groups_view.py +++ b/app/scodoc/sco_groups_view.py @@ -815,7 +815,7 @@ def tab_absences_html(groups_infos, etat=None): % (groups_infos.base_url, groups_infos.groups_titles), """
  • Trombinoscope en PDF
  • """ % groups_infos.groups_query_args, - """
  • Trombinoscope en PDF (format "IUT de Tours", beta)
  • """ + """
  • Trombinoscope en PDF (format "IUT de Tours")
  • """ % groups_infos.groups_query_args, """
  • Feuille relevé absences hebdomadaire (beta)
  • """ % groups_infos.groups_query_args, diff --git a/app/scodoc/sco_preferences.py b/app/scodoc/sco_preferences.py index da3e1a4ef..b38fb736f 100644 --- a/app/scodoc/sco_preferences.py +++ b/app/scodoc/sco_preferences.py @@ -762,7 +762,7 @@ class BasePreferences(object): { "initvalue": "Helvetica", "title": "Police de caractère principale", - "explanation": "pour les pdf", + "explanation": "pour les pdf (Helvetica est recommandée)", "size": 25, "category": "pdf", }, diff --git a/app/scodoc/sco_trombino_tours.py b/app/scodoc/sco_trombino_tours.py index e7f2266fb..3861bb74f 100644 --- a/app/scodoc/sco_trombino_tours.py +++ b/app/scodoc/sco_trombino_tours.py @@ -44,6 +44,7 @@ from app.scodoc import sco_groups_view from app.scodoc import sco_preferences from app.scodoc import sco_trombino from app.scodoc import sco_etud +from app.scodoc.sco_exceptions import ScoPDFFormatError from app.scodoc.sco_pdf import * @@ -268,7 +269,10 @@ def pdf_trombino_tours( preferences=sco_preferences.SemPreferences(), ) ) - document.build(objects) + try: + document.build(objects) + except (ValueError, KeyError) as exc: + raise ScoPDFFormatError(str(exc)) from exc data = report.getvalue() return scu.sendPDFFile(data, filename)