diff --git a/app/but/bulletin_but_court.py b/app/but/bulletin_but_court.py index a4fc6ec1..41f989a1 100644 --- a/app/but/bulletin_but_court.py +++ b/app/but/bulletin_but_court.py @@ -124,7 +124,9 @@ def _build_bulletin_but_infos( formsemestre, bulletins_sem.res ) if warn_html: - raise ScoValueError("Formation mal configurée pour le BUT" + warn_html) + raise ScoValueError( + "Formation mal configurée pour le BUT" + warn_html, safe=True + ) ue_validation_by_niveau = validations_view.get_ue_validation_by_niveau( refcomp, etud ) diff --git a/app/comp/res_classic.py b/app/comp/res_classic.py index 113faa0b..59f3790e 100644 --- a/app/comp/res_classic.py +++ b/app/comp/res_classic.py @@ -242,7 +242,8 @@ class ResultatsSemestreClassic(NotesTableCompat): ) }">saisir le coefficient de cette UE avant de continuer

- """ + """, + safe=True, ) diff --git a/app/comp/res_common.py b/app/comp/res_common.py index 9915c616..267f5e7f 100644 --- a/app/comp/res_common.py +++ b/app/comp/res_common.py @@ -518,7 +518,8 @@ class ResultatsSemestre(ResultatsCache): Corrigez ou faite corriger le programme via cette page. - """ + """, + safe=True, ) else: # Coefs de l'UE capitalisée en formation classique: diff --git a/app/scodoc/sco_bulletins_pdf.py b/app/scodoc/sco_bulletins_pdf.py index 80cee3a4..dddd4430 100644 --- a/app/scodoc/sco_bulletins_pdf.py +++ b/app/scodoc/sco_bulletins_pdf.py @@ -122,7 +122,8 @@ def replacement_function(match) -> str: return r'' % (match.group(2), logo.filepath, match.group(4)) raise ScoValueError( 'balise "%s": logo "%s" introuvable' - % (pydoc.html.escape(balise), pydoc.html.escape(name)) + % (pydoc.html.escape(balise), pydoc.html.escape(name)), + safe=True, ) diff --git a/app/scodoc/sco_dump_db.py b/app/scodoc/sco_dump_db.py index a74fab8d..1bef5439 100644 --- a/app/scodoc/sco_dump_db.py +++ b/app/scodoc/sco_dump_db.py @@ -216,11 +216,11 @@ def _drop_ano_db(ano_db_name): log("_drop_ano_db: no temp db, nothing to drop") return cmd = ["dropdb", ano_db_name] - log("sco_dump_and_send_db: {}".format(cmd)) + log(f"sco_dump_and_send_db: {cmd}") try: _ = subprocess.check_output(cmd) - except subprocess.CalledProcessError as e: - log("sco_dump_and_send_db: exception dropdb {}".format(e)) + except subprocess.CalledProcessError as exc: + log(f"sco_dump_and_send_db: exception dropdb {exc}") raise ScoValueError( - "erreur lors de la suppression de la base {}".format(ano_db_name) - ) + f"erreur lors de la suppression de la base {ano_db_name}" + ) from exc diff --git a/app/scodoc/sco_edit_formation.py b/app/scodoc/sco_edit_formation.py index 1a951e99..6def9f0f 100644 --- a/app/scodoc/sco_edit_formation.py +++ b/app/scodoc/sco_edit_formation.py @@ -326,6 +326,7 @@ def do_formation_create(args: dict) -> Formation: scodoc_dept=g.scodoc_dept, formation_id=formation.id, ), + safe=True, ) from exc ScolarNews.add( diff --git a/app/scodoc/sco_exceptions.py b/app/scodoc/sco_exceptions.py index aa2d04d0..2e61608c 100644 --- a/app/scodoc/sco_exceptions.py +++ b/app/scodoc/sco_exceptions.py @@ -45,13 +45,17 @@ class ScoInvalidCSRF(ScoException): class ScoValueError(ScoException): - "Exception avec page d'erreur utilisateur, et qui stoque dest_url" + """Exception avec page d'erreur utilisateur + - dest_url : url où aller après la page d'erreur + - safe (default False): si vrai, affiche le message non html quoté. + """ # mal nommée: super classe de toutes les exceptions avec page # d'erreur gentille. - def __init__(self, msg, dest_url=None): + def __init__(self, msg, dest_url=None, safe=False): super().__init__(msg) self.dest_url = dest_url + self.safe = safe # utilisé par template sco_value_error.j2 class ScoPermissionDenied(ScoValueError): diff --git a/app/scodoc/sco_synchro_etuds.py b/app/scodoc/sco_synchro_etuds.py index 3f5008e3..19c64367 100644 --- a/app/scodoc/sco_synchro_etuds.py +++ b/app/scodoc/sco_synchro_etuds.py @@ -115,7 +115,8 @@ def formsemestre_synchro_etuds( url_for('notes.formsemestre_editwithmodules', scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre.id) }">Modifier ce semestre) - """ + """, + safe=True, ) footer = html_sco_header.sco_footer() base_url = url_for( diff --git a/app/templates/sco_value_error.j2 b/app/templates/sco_value_error.j2 index 6fa329c7..2a488c93 100644 --- a/app/templates/sco_value_error.j2 +++ b/app/templates/sco_value_error.j2 @@ -5,15 +5,19 @@

Erreur !

-{{ exc }} +{% if exc.safe %} + {{ exc | safe }} +{% else %} + {{ exc }} +{% endif %}
{% if g.scodoc_dept %} - continuer + continuer {% elif exc.dest_url %} - continuer + continuer {% else %} - retour page d'accueil + retour page d'accueil {% endif %}
diff --git a/app/views/notes.py b/app/views/notes.py index 1add286a..51a74b3e 100644 --- a/app/views/notes.py +++ b/app/views/notes.py @@ -1436,14 +1436,14 @@ def formsemestre_desinscription(etudid, formsemestre_id, dialog_confirmed=False) if nt.etud_has_decision(etudid): raise ScoValueError( f"""Désinscription impossible: l'étudiant a une décision de jury - (la supprimer avant si nécessaire: - supprimer décision jury - ) - """ + }">supprimer décision jury) + """, + safe=True, ) if not dialog_confirmed: etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]