From cb21043f31e31576f77f1210db966d5ce3648f88 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 30 Jan 2023 18:25:17 -0300 Subject: [PATCH] Templates Jinja2: extension .j2 au lieu de .html --- app/__init__.py | 12 +- app/auth/email.py | 2 +- app/auth/routes.py | 10 +- app/but/jury_but_view.py | 2 +- app/entreprises/routes.py | 84 +++--- app/forms/main/config_logos.py | 4 +- app/forms/main/config_main.py | 2 +- app/scodoc/html_sco_header.py | 2 +- app/scodoc/html_sidebar.py | 2 +- app/scodoc/sco_archives_etud.py | 2 +- app/scodoc/sco_bulletins.py | 4 +- app/scodoc/sco_edit_module.py | 6 +- app/scodoc/sco_evaluation_edit.py | 2 +- app/scodoc/sco_formsemestre_status.py | 2 +- app/scodoc/sco_groups_edit.py | 2 +- app/scodoc/sco_placement.py | 2 +- app/scodoc/sco_trombino.py | 2 +- app/templates/{about.html => about.j2} | 10 +- ...hange_password.html => change_password.j2} | 40 +-- app/templates/auth/{login.html => login.j2} | 2 +- .../auth/{register.html => register.j2} | 2 +- ...{reset_password.html => reset_password.j2} | 2 +- ...request.html => reset_password_request.j2} | 2 +- ...active_user.html => toogle_active_user.j2} | 2 +- ...{user_info_page.html => user_info_page.j2} | 14 +- app/templates/{base.html => base.j2} | 24 +- app/templates/{bul_foot.html => bul_foot.j2} | 0 app/templates/{bul_head.html => bul_head.j2} | 0 .../but/{bulletin.html => bulletin.j2} | 6 +- ..._jury.html => documentation_codes_jury.j2} | 0 ...ml => formsemestre_validation_auto_but.j2} | 2 +- .../{refcomp_assoc.html => refcomp_assoc.j2} | 10 +- app/templates/but/refcomp_load.html | 30 -- app/templates/but/refcomp_load.j2 | 31 ++ .../{refcomp_show.html => refcomp_show.j2} | 2 +- .../{refcomp_table.html => refcomp_table.j2} | 2 +- ...cisions.html => config_codes_decisions.j2} | 2 +- .../{config_dept.html => config_dept.j2} | 0 app/templates/config_logos.html | 132 --------- app/templates/config_logos.j2 | 132 +++++++++ .../{configuration.html => configuration.j2} | 66 ++--- ...{confirm_dialog.html => confirm_dialog.j2} | 3 +- .../{create_dept.html => create_dept.j2} | 2 +- app/templates/dept_news.html | 47 ---- app/templates/dept_news.j2 | 47 ++++ ...{reset_password.html => reset_password.j2} | 0 .../email/{welcome.html => welcome.j2} | 0 ...{_correspondant.html => _correspondant.j2} | 0 .../entreprises/{_offre.html => _offre.j2} | 0 app/templates/entreprises/contacts.html | 104 ------- app/templates/entreprises/contacts.j2 | 109 +++++++ app/templates/entreprises/correspondants.html | 93 ------ app/templates/entreprises/correspondants.j2 | 95 +++++++ app/templates/entreprises/entreprises.html | 133 --------- app/templates/entreprises/entreprises.j2 | 143 ++++++++++ .../entreprises/entreprises_validation.html | 95 ------- .../entreprises/entreprises_validation.j2 | 98 +++++++ app/templates/entreprises/error.html | 14 - app/templates/entreprises/error.j2 | 14 + .../entreprises/fiche_entreprise.html | 227 --------------- app/templates/entreprises/fiche_entreprise.j2 | 253 +++++++++++++++++ .../fiche_entreprise_validation.html | 84 ------ .../fiche_entreprise_validation.j2 | 86 ++++++ app/templates/entreprises/form.html | 62 ---- app/templates/entreprises/form.j2 | 62 ++++ .../form_ajout_correspondants.html | 91 ------ .../entreprises/form_ajout_correspondants.j2 | 91 ++++++ .../entreprises/form_ajout_entreprise.html | 58 ---- .../entreprises/form_ajout_entreprise.j2 | 58 ++++ .../form_ajout_stage_apprentissage.html | 36 --- .../form_ajout_stage_apprentissage.j2 | 36 +++ .../entreprises/form_confirmation.html | 15 - .../entreprises/form_confirmation.j2 | 15 + .../entreprises/form_envoi_offre.html | 88 ------ app/templates/entreprises/form_envoi_offre.j2 | 88 ++++++ .../form_modification_entreprise.html | 68 ----- .../form_modification_entreprise.j2 | 68 +++++ .../form_validate_confirmation.html | 15 - .../entreprises/form_validate_confirmation.j2 | 15 + app/templates/entreprises/import_donnees.html | 149 ---------- app/templates/entreprises/import_donnees.j2 | 265 ++++++++++++++++++ app/templates/entreprises/logs.html | 54 ---- app/templates/entreprises/logs.j2 | 57 ++++ .../entreprises/logs_entreprise.html | 56 ---- app/templates/entreprises/logs_entreprise.j2 | 62 ++++ .../entreprises/{nav.html => nav.j2} | 0 .../entreprises/offres_expirees.html | 29 -- app/templates/entreprises/offres_expirees.j2 | 30 ++ app/templates/entreprises/offres_recues.html | 52 ---- app/templates/entreprises/offres_recues.j2 | 58 ++++ app/templates/entreprises/preferences.html | 17 -- app/templates/entreprises/preferences.j2 | 17 ++ .../{error_500.html => error_500.j2} | 18 +- .../{error_503.html => error_503.j2} | 0 ...ess_denied.html => error_access_denied.j2} | 2 +- .../{testcheckbox.html => testcheckbox.j2} | 2 +- ...shed_messages.html => flashed_messages.j2} | 0 ...tre_header.html => formsemestre_header.j2} | 0 ..._title.html => formsemestre_page_title.j2} | 0 app/templates/main/{index.html => index.j2} | 2 +- app/templates/pn/form_descr.j2 | 2 +- app/templates/pn/ue_infos.j2 | 119 ++++---- app/templates/{sco_page.html => sco_page.j2} | 4 +- ...co_value_error.html => sco_value_error.j2} | 2 +- app/templates/{scodoc.html => scodoc.j2} | 15 +- .../forms/{placement.html => placement.j2} | 0 .../help/{evaluations.html => evaluations.j2} | 0 .../scodoc/help/{modules.html => modules.j2} | 44 +-- .../{affect_groups.html => affect_groups.j2} | 0 ...tition_editor.html => partition_editor.j2} | 0 ...port_files.html => photos_import_files.j2} | 2 +- app/templates/{sidebar.html => sidebar.j2} | 0 .../{sidebar_dept.html => sidebar_dept.j2} | 0 app/views/notes.py | 8 +- app/views/refcomp.py | 8 +- app/views/scodoc.py | 8 +- app/views/scolar.py | 8 +- app/views/users.py | 8 +- 118 files changed, 2229 insertions(+), 2037 deletions(-) rename app/templates/{about.html => about.j2} (56%) rename app/templates/auth/{change_password.html => change_password.j2} (57%) rename app/templates/auth/{login.html => login.j2} (96%) rename app/templates/auth/{register.html => register.j2} (90%) rename app/templates/auth/{reset_password.html => reset_password.j2} (94%) rename app/templates/auth/{reset_password_request.html => reset_password_request.j2} (90%) rename app/templates/auth/{toogle_active_user.html => toogle_active_user.j2} (95%) rename app/templates/auth/{user_info_page.html => user_info_page.j2} (87%) rename app/templates/{base.html => base.j2} (82%) rename app/templates/{bul_foot.html => bul_foot.j2} (100%) rename app/templates/{bul_head.html => bul_head.j2} (100%) rename app/templates/but/{bulletin.html => bulletin.j2} (92%) rename app/templates/but/{documentation_codes_jury.html => documentation_codes_jury.j2} (100%) rename app/templates/but/{formsemestre_validation_auto_but.html => formsemestre_validation_auto_but.j2} (96%) rename app/templates/but/{refcomp_assoc.html => refcomp_assoc.j2} (91%) delete mode 100644 app/templates/but/refcomp_load.html create mode 100644 app/templates/but/refcomp_load.j2 rename app/templates/but/{refcomp_show.html => refcomp_show.j2} (96%) rename app/templates/but/{refcomp_table.html => refcomp_table.j2} (97%) rename app/templates/{config_codes_decisions.html => config_codes_decisions.j2} (95%) rename app/templates/{config_dept.html => config_dept.j2} (100%) delete mode 100644 app/templates/config_logos.html create mode 100644 app/templates/config_logos.j2 rename app/templates/{configuration.html => configuration.j2} (51%) rename app/templates/{confirm_dialog.html => confirm_dialog.j2} (89%) rename app/templates/{create_dept.html => create_dept.j2} (90%) delete mode 100644 app/templates/dept_news.html create mode 100644 app/templates/dept_news.j2 rename app/templates/email/{reset_password.html => reset_password.j2} (100%) rename app/templates/email/{welcome.html => welcome.j2} (100%) rename app/templates/entreprises/{_correspondant.html => _correspondant.j2} (100%) rename app/templates/entreprises/{_offre.html => _offre.j2} (100%) delete mode 100644 app/templates/entreprises/contacts.html create mode 100644 app/templates/entreprises/contacts.j2 delete mode 100644 app/templates/entreprises/correspondants.html create mode 100644 app/templates/entreprises/correspondants.j2 delete mode 100644 app/templates/entreprises/entreprises.html create mode 100644 app/templates/entreprises/entreprises.j2 delete mode 100644 app/templates/entreprises/entreprises_validation.html create mode 100644 app/templates/entreprises/entreprises_validation.j2 delete mode 100644 app/templates/entreprises/error.html create mode 100644 app/templates/entreprises/error.j2 delete mode 100644 app/templates/entreprises/fiche_entreprise.html create mode 100644 app/templates/entreprises/fiche_entreprise.j2 delete mode 100644 app/templates/entreprises/fiche_entreprise_validation.html create mode 100644 app/templates/entreprises/fiche_entreprise_validation.j2 delete mode 100644 app/templates/entreprises/form.html create mode 100644 app/templates/entreprises/form.j2 delete mode 100644 app/templates/entreprises/form_ajout_correspondants.html create mode 100644 app/templates/entreprises/form_ajout_correspondants.j2 delete mode 100644 app/templates/entreprises/form_ajout_entreprise.html create mode 100644 app/templates/entreprises/form_ajout_entreprise.j2 delete mode 100644 app/templates/entreprises/form_ajout_stage_apprentissage.html create mode 100644 app/templates/entreprises/form_ajout_stage_apprentissage.j2 delete mode 100644 app/templates/entreprises/form_confirmation.html create mode 100644 app/templates/entreprises/form_confirmation.j2 delete mode 100644 app/templates/entreprises/form_envoi_offre.html create mode 100644 app/templates/entreprises/form_envoi_offre.j2 delete mode 100644 app/templates/entreprises/form_modification_entreprise.html create mode 100644 app/templates/entreprises/form_modification_entreprise.j2 delete mode 100644 app/templates/entreprises/form_validate_confirmation.html create mode 100644 app/templates/entreprises/form_validate_confirmation.j2 delete mode 100644 app/templates/entreprises/import_donnees.html create mode 100644 app/templates/entreprises/import_donnees.j2 delete mode 100644 app/templates/entreprises/logs.html create mode 100644 app/templates/entreprises/logs.j2 delete mode 100644 app/templates/entreprises/logs_entreprise.html create mode 100644 app/templates/entreprises/logs_entreprise.j2 rename app/templates/entreprises/{nav.html => nav.j2} (100%) delete mode 100644 app/templates/entreprises/offres_expirees.html create mode 100644 app/templates/entreprises/offres_expirees.j2 delete mode 100644 app/templates/entreprises/offres_recues.html create mode 100644 app/templates/entreprises/offres_recues.j2 delete mode 100644 app/templates/entreprises/preferences.html create mode 100644 app/templates/entreprises/preferences.j2 rename app/templates/{error_500.html => error_500.j2} (76%) rename app/templates/{error_503.html => error_503.j2} (100%) rename app/templates/{error_access_denied.html => error_access_denied.j2} (94%) rename app/templates/essais/{testcheckbox.html => testcheckbox.j2} (95%) rename app/templates/{flashed_messages.html => flashed_messages.j2} (100%) rename app/templates/{formsemestre_header.html => formsemestre_header.j2} (100%) rename app/templates/{formsemestre_page_title.html => formsemestre_page_title.j2} (100%) rename app/templates/main/{index.html => index.j2} (98%) rename app/templates/{sco_page.html => sco_page.j2} (97%) rename app/templates/{sco_value_error.html => sco_value_error.j2} (93%) rename app/templates/{scodoc.html => scodoc.j2} (87%) rename app/templates/scodoc/forms/{placement.html => placement.j2} (100%) rename app/templates/scodoc/help/{evaluations.html => evaluations.j2} (100%) rename app/templates/scodoc/help/{modules.html => modules.j2} (56%) rename app/templates/scolar/{affect_groups.html => affect_groups.j2} (100%) rename app/templates/scolar/{partition_editor.html => partition_editor.j2} (100%) rename app/templates/scolar/{photos_import_files.html => photos_import_files.j2} (96%) rename app/templates/{sidebar.html => sidebar.j2} (100%) rename app/templates/{sidebar_dept.html => sidebar_dept.j2} (100%) diff --git a/app/__init__.py b/app/__init__.py index 51e122cd55..72cc1cb726 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -26,6 +26,7 @@ from flask_mail import Mail from flask_bootstrap import Bootstrap from flask_moment import Moment from flask_caching import Cache +from jinja2 import select_autoescape import sqlalchemy from app.scodoc.sco_exceptions import ( @@ -61,11 +62,11 @@ cache = Cache( def handle_sco_value_error(exc): - return render_template("sco_value_error.html", exc=exc), 404 + return render_template("sco_value_error.j2", exc=exc), 404 def handle_access_denied(exc): - return render_template("error_access_denied.html", exc=exc), 403 + return render_template("error_access_denied.j2", exc=exc), 403 def internal_server_error(exc): @@ -75,7 +76,7 @@ def internal_server_error(exc): return ( render_template( - "error_500.html", + "error_500.j2", SCOVERSION=sco_version.SCOVERSION, date=datetime.datetime.now().isoformat(), exc=exc, @@ -146,7 +147,7 @@ def render_raw_html(template_filename: str, **args) -> str: def postgresql_server_error(e): """Erreur de connection au serveur postgresql (voir notesdb.open_db_connection)""" - return render_raw_html("error_503.html", SCOVERSION=sco_version.SCOVERSION), 503 + return render_raw_html("error_503.j2", SCOVERSION=sco_version.SCOVERSION), 503 class LogRequestFormatter(logging.Formatter): @@ -275,6 +276,9 @@ def create_app(config_class=DevConfig): from app.api import api_bp from app.api import api_web_bp + # Enable autoescaping of all templates, including .j2 + app.jinja_env.autoescape = select_autoescape(default_for_string=True, default=True) + # https://scodoc.fr/ScoDoc app.register_blueprint(scodoc_bp) # https://scodoc.fr/ScoDoc/RT/Scolarite/... diff --git a/app/auth/email.py b/app/auth/email.py index 617596910f..9ea8f23e0b 100644 --- a/app/auth/email.py +++ b/app/auth/email.py @@ -11,5 +11,5 @@ def send_password_reset_email(user): sender=current_app.config["SCODOC_MAIL_FROM"], recipients=[user.email], text_body=render_template("email/reset_password.txt", user=user, token=token), - html_body=render_template("email/reset_password.html", user=user, token=token), + html_body=render_template("email/reset_password.j2", user=user, token=token), ) diff --git a/app/auth/routes.py b/app/auth/routes.py index 46d144d63b..2c1594bc84 100644 --- a/app/auth/routes.py +++ b/app/auth/routes.py @@ -42,7 +42,7 @@ def login(): return form.redirect("scodoc.index") message = request.args.get("message", "") return render_template( - "auth/login.html", title=_("Sign In"), form=form, message=message + "auth/login.j2", title=_("Sign In"), form=form, message=message ) @@ -65,9 +65,7 @@ def create_user(): db.session.commit() flash(f"Utilisateur {user.user_name} créé") return redirect(url_for("scodoc.index")) - return render_template( - "auth/register.html", title="Création utilisateur", form=form - ) + return render_template("auth/register.j2", title="Création utilisateur", form=form) @bp.route("/reset_password_request", methods=["GET", "POST"]) @@ -98,7 +96,7 @@ def reset_password_request(): ) return redirect(url_for("auth.login")) return render_template( - "auth/reset_password_request.html", title=_("Reset Password"), form=form + "auth/reset_password_request.j2", title=_("Reset Password"), form=form ) @@ -116,7 +114,7 @@ def reset_password(token): db.session.commit() flash(_("Votre mot de passe a été changé.")) return redirect(url_for("auth.login")) - return render_template("auth/reset_password.html", form=form, user=user) + return render_template("auth/reset_password.j2", form=form, user=user) @bp.route("/reset_standard_roles_permissions", methods=["GET", "POST"]) diff --git a/app/but/jury_but_view.py b/app/but/jury_but_view.py index a58f41e2c0..1593447442 100644 --- a/app/but/jury_but_view.py +++ b/app/but/jury_but_view.py @@ -500,7 +500,7 @@ def jury_but_semestriel( H.append("") H.append( render_template( - "but/documentation_codes_jury.html", + "but/documentation_codes_jury.j2", nom_univ=f"""Export {sco_preferences.get_preference("InstituteName") or sco_preferences.get_preference("UnivName") or "Apogée"}""", diff --git a/app/entreprises/routes.py b/app/entreprises/routes.py index 2d4195004a..e50ebf7134 100644 --- a/app/entreprises/routes.py +++ b/app/entreprises/routes.py @@ -89,7 +89,7 @@ def index(): visible=True, association=True, siret_provisoire=True ) return render_template( - "entreprises/entreprises.html", + "entreprises/entreprises.j2", title="Entreprises", entreprises=entreprises, logs=logs, @@ -109,7 +109,7 @@ def logs(): EntrepriseHistorique.date.desc() ).paginate(page=page, per_page=20) return render_template( - "entreprises/logs.html", + "entreprises/logs.j2", title="Logs", logs=logs, ) @@ -134,7 +134,7 @@ def correspondants(): .all() ) return render_template( - "entreprises/correspondants.html", + "entreprises/correspondants.j2", title="Correspondants", correspondants=correspondants, logs=logs, @@ -149,7 +149,7 @@ def validation(): """ entreprises = Entreprise.query.filter_by(visible=False).all() return render_template( - "entreprises/entreprises_validation.html", + "entreprises/entreprises_validation.j2", title="Validation entreprises", entreprises=entreprises, ) @@ -167,7 +167,7 @@ def fiche_entreprise_validation(entreprise_id): description=f"fiche entreprise (validation) {entreprise_id} inconnue" ) return render_template( - "entreprises/fiche_entreprise_validation.html", + "entreprises/fiche_entreprise_validation.j2", title="Validation fiche entreprise", entreprise=entreprise, ) @@ -205,7 +205,7 @@ def validate_entreprise(entreprise_id): flash("L'entreprise a été validé et ajouté à la liste.") return redirect(url_for("entreprises.validation")) return render_template( - "entreprises/form_validate_confirmation.html", + "entreprises/form_validate_confirmation.j2", title="Validation entreprise", form=form, ) @@ -242,7 +242,7 @@ def delete_validation_entreprise(entreprise_id): flash("L'entreprise a été supprimé de la liste des entreprise à valider.") return redirect(url_for("entreprises.validation")) return render_template( - "entreprises/form_confirmation.html", + "entreprises/form_confirmation.j2", title="Supression entreprise", form=form, info_message="Cliquez sur le bouton Supprimer pour confirmer votre supression", @@ -282,7 +282,7 @@ def offres_recues(): files.append(file) offres_recues_with_files.append([envoi_offre, offre, files, correspondant]) return render_template( - "entreprises/offres_recues.html", + "entreprises/offres_recues.j2", title="Offres reçues", offres_recues=offres_recues_with_files, ) @@ -321,7 +321,7 @@ def preferences(): form.mail_entreprise.data = EntreprisePreferences.get_email_notifications() form.check_siret.data = int(EntreprisePreferences.get_check_siret()) return render_template( - "entreprises/preferences.html", + "entreprises/preferences.j2", title="Préférences", form=form, ) @@ -357,7 +357,7 @@ def add_entreprise(): db.session.rollback() flash("Une erreur est survenue veuillez réessayer.") return render_template( - "entreprises/form_ajout_entreprise.html", + "entreprises/form_ajout_entreprise.j2", title="Ajout entreprise avec correspondant", form=form, ) @@ -408,7 +408,7 @@ def add_entreprise(): flash("L'entreprise a été ajouté à la liste pour la validation.") return redirect(url_for("entreprises.index")) return render_template( - "entreprises/form_ajout_entreprise.html", + "entreprises/form_ajout_entreprise.j2", title="Ajout entreprise avec correspondant", form=form, ) @@ -446,7 +446,7 @@ def fiche_entreprise(entreprise_id): .all() ) return render_template( - "entreprises/fiche_entreprise.html", + "entreprises/fiche_entreprise.j2", title="Fiche entreprise", entreprise=entreprise, offres=offres_with_files, @@ -472,7 +472,7 @@ def logs_entreprise(entreprise_id): .paginate(page=page, per_page=20) ) return render_template( - "entreprises/logs_entreprise.html", + "entreprises/logs_entreprise.j2", title="Logs", logs=logs, entreprise=entreprise, @@ -490,7 +490,7 @@ def offres_expirees(entreprise_id): ).first_or_404(description=f"fiche entreprise {entreprise_id} inconnue") offres_with_files = are.get_offres_expirees_with_files(entreprise.offres) return render_template( - "entreprises/offres_expirees.html", + "entreprises/offres_expirees.j2", title="Offres expirées", entreprise=entreprise, offres_expirees=offres_with_files, @@ -574,7 +574,7 @@ def edit_entreprise(entreprise_id): form.pays.data = entreprise.pays form.association.data = entreprise.association return render_template( - "entreprises/form_modification_entreprise.html", + "entreprises/form_modification_entreprise.j2", title="Modification entreprise", form=form, ) @@ -610,7 +610,7 @@ def fiche_entreprise_desactiver(entreprise_id): url_for("entreprises.fiche_entreprise", entreprise_id=entreprise.id) ) return render_template( - "entreprises/form_confirmation.html", + "entreprises/form_confirmation.j2", title="Désactiver entreprise", form=form, info_message="Cliquez sur le bouton Modifier pour confirmer la désactivation", @@ -646,7 +646,7 @@ def fiche_entreprise_activer(entreprise_id): url_for("entreprises.fiche_entreprise", entreprise_id=entreprise.id) ) return render_template( - "entreprises/form_confirmation.html", + "entreprises/form_confirmation.j2", title="Activer entreprise", form=form, info_message="Cliquez sur le bouton Modifier pour confirmer l'activaction", @@ -692,7 +692,7 @@ def add_taxe_apprentissage(entreprise_id): url_for("entreprises.fiche_entreprise", entreprise_id=entreprise.id) ) return render_template( - "entreprises/form.html", + "entreprises/form.j2", title="Ajout taxe apprentissage", form=form, ) @@ -735,7 +735,7 @@ def edit_taxe_apprentissage(entreprise_id, taxe_id): form.montant.data = taxe.montant form.notes.data = taxe.notes return render_template( - "entreprises/form.html", + "entreprises/form.j2", title="Modification taxe apprentissage", form=form, ) @@ -775,7 +775,7 @@ def delete_taxe_apprentissage(entreprise_id, taxe_id): url_for("entreprises.fiche_entreprise", entreprise_id=taxe.entreprise_id) ) return render_template( - "entreprises/form_confirmation.html", + "entreprises/form_confirmation.j2", title="Supprimer taxe apprentissage", form=form, info_message="Cliquez sur le bouton Supprimer pour confirmer votre supression", @@ -845,7 +845,7 @@ def add_offre(entreprise_id): url_for("entreprises.fiche_entreprise", entreprise_id=entreprise.id) ) return render_template( - "entreprises/form.html", + "entreprises/form.j2", title="Ajout offre", form=form, ) @@ -921,7 +921,7 @@ def edit_offre(entreprise_id, offre_id): form.expiration_date.data = offre.expiration_date form.depts.data = offre_depts_list return render_template( - "entreprises/form.html", + "entreprises/form.j2", title="Modification offre", form=form, ) @@ -971,7 +971,7 @@ def delete_offre(entreprise_id, offre_id): url_for("entreprises.fiche_entreprise", entreprise_id=offre.entreprise_id) ) return render_template( - "entreprises/form_confirmation.html", + "entreprises/form_confirmation.j2", title="Supression offre", form=form, info_message="Cliquez sur le bouton Supprimer pour confirmer votre supression", @@ -1047,7 +1047,7 @@ def add_site(entreprise_id): url_for("entreprises.fiche_entreprise", entreprise_id=entreprise.id) ) return render_template( - "entreprises/form.html", + "entreprises/form.j2", title="Ajout site", form=form, ) @@ -1098,7 +1098,7 @@ def edit_site(entreprise_id, site_id): form.ville.data = site.ville form.pays.data = site.pays return render_template( - "entreprises/form.html", + "entreprises/form.j2", title="Modification site", form=form, ) @@ -1154,7 +1154,7 @@ def add_correspondant(entreprise_id, site_id): url_for("entreprises.fiche_entreprise", entreprise_id=site.entreprise_id) ) return render_template( - "entreprises/form_ajout_correspondants.html", + "entreprises/form_ajout_correspondants.j2", title="Ajout correspondant", form=form, ) @@ -1234,7 +1234,7 @@ def edit_correspondant(entreprise_id, site_id, correspondant_id): form.origine.data = correspondant.origine form.notes.data = correspondant.notes return render_template( - "entreprises/form.html", + "entreprises/form.j2", title="Modification correspondant", form=form, ) @@ -1290,7 +1290,7 @@ def delete_correspondant(entreprise_id, site_id, correspondant_id): ) ) return render_template( - "entreprises/form_confirmation.html", + "entreprises/form_confirmation.j2", title="Supression correspondant", form=form, info_message="Cliquez sur le bouton Supprimer pour confirmer votre supression", @@ -1308,7 +1308,7 @@ def contacts(entreprise_id): ).first_or_404(description=f"entreprise {entreprise_id} inconnue") contacts = EntrepriseContact.query.filter_by(entreprise=entreprise.id).all() return render_template( - "entreprises/contacts.html", + "entreprises/contacts.j2", title="Liste des contacts", contacts=contacts, entreprise=entreprise, @@ -1365,7 +1365,7 @@ def add_contact(entreprise_id): db.session.commit() return redirect(url_for("entreprises.contacts", entreprise_id=entreprise.id)) return render_template( - "entreprises/form.html", + "entreprises/form.j2", title="Ajout contact", form=form, ) @@ -1421,7 +1421,7 @@ def edit_contact(entreprise_id, contact_id): ) form.notes.data = contact.notes return render_template( - "entreprises/form.html", + "entreprises/form.j2", title="Modification contact", form=form, ) @@ -1459,7 +1459,7 @@ def delete_contact(entreprise_id, contact_id): url_for("entreprises.contacts", entreprise_id=contact.entreprise) ) return render_template( - "entreprises/form_confirmation.html", + "entreprises/form_confirmation.j2", title="Supression contact", form=form, info_message="Cliquez sur le bouton Supprimer pour confirmer votre supression", @@ -1525,7 +1525,7 @@ def add_stage_apprentissage(entreprise_id): url_for("entreprises.fiche_entreprise", entreprise_id=entreprise.id) ) return render_template( - "entreprises/form_ajout_stage_apprentissage.html", + "entreprises/form_ajout_stage_apprentissage.j2", title="Ajout stage / apprentissage", form=form, ) @@ -1599,7 +1599,7 @@ def edit_stage_apprentissage(entreprise_id, stage_apprentissage_id): form.date_fin.data = stage_apprentissage.date_fin form.notes.data = stage_apprentissage.notes return render_template( - "entreprises/form_ajout_stage_apprentissage.html", + "entreprises/form_ajout_stage_apprentissage.j2", title="Modification stage / apprentissage", form=form, ) @@ -1640,7 +1640,7 @@ def delete_stage_apprentissage(entreprise_id, stage_apprentissage_id): ) ) return render_template( - "entreprises/form_confirmation.html", + "entreprises/form_confirmation.j2", title="Supression stage/apprentissage", form=form, info_message="Cliquez sur le bouton Supprimer pour confirmer votre supression", @@ -1690,7 +1690,7 @@ def envoyer_offre(entreprise_id, offre_id): url_for("entreprises.fiche_entreprise", entreprise_id=offre.entreprise_id) ) return render_template( - "entreprises/form_envoi_offre.html", + "entreprises/form_envoi_offre.j2", title="Envoyer une offre", form=form, ) @@ -1816,7 +1816,7 @@ def import_donnees(): db.session.rollback() flash("Une erreur est survenue veuillez réessayer.") return render_template( - "entreprises/import_donnees.html", + "entreprises/import_donnees.j2", title="Importation données", form=form, ) @@ -1845,7 +1845,7 @@ def import_donnees(): db.session.commit() flash(f"Importation réussie") return render_template( - "entreprises/import_donnees.html", + "entreprises/import_donnees.j2", title="Importation données", form=form, entreprises_import=entreprises_import, @@ -1853,7 +1853,7 @@ def import_donnees(): correspondants_import=correspondants, ) return render_template( - "entreprises/import_donnees.html", title="Importation données", form=form + "entreprises/import_donnees.j2", title="Importation données", form=form ) @@ -1927,7 +1927,7 @@ def add_offre_file(entreprise_id, offre_id): url_for("entreprises.fiche_entreprise", entreprise_id=offre.entreprise_id) ) return render_template( - "entreprises/form.html", + "entreprises/form.j2", title="Ajout fichier à une offre", form=form, ) @@ -1969,7 +1969,7 @@ def delete_offre_file(entreprise_id, offre_id, filedir): ) ) return render_template( - "entreprises/form_confirmation.html", + "entreprises/form_confirmation.j2", title="Suppression fichier d'une offre", form=form, info_message="Cliquez sur le bouton Supprimer pour confirmer votre supression", @@ -1981,4 +1981,4 @@ def not_found_error_handler(e): """ Renvoie une page d'erreur pour l'erreur 404 """ - return render_template("entreprises/error.html", title="Erreur", e=e) + return render_template("entreprises/error.j2", title="Erreur", e=e) diff --git a/app/forms/main/config_logos.py b/app/forms/main/config_logos.py index 2a0051f0d0..2a54dd7c70 100644 --- a/app/forms/main/config_logos.py +++ b/app/forms/main/config_logos.py @@ -171,7 +171,7 @@ class AddLogoForm(FlaskForm): class LogoForm(FlaskForm): - """Embed both presentation of a logo (cf. template file configuration.html) + """Embed both presentation of a logo (cf. template file configuration.j2) and all its data and UI action (change, delete)""" dept_key = HiddenField() @@ -434,7 +434,7 @@ def config_logos(): scu.flash_errors(form) return render_template( - "config_logos.html", + "config_logos.j2", scodoc_dept=None, title="Configuration ScoDoc", form=form, diff --git a/app/forms/main/config_main.py b/app/forms/main/config_main.py index 205c88facd..4cc539fb18 100644 --- a/app/forms/main/config_main.py +++ b/app/forms/main/config_main.py @@ -133,7 +133,7 @@ def configuration(): return redirect(url_for("scodoc.index")) return render_template( - "configuration.html", + "configuration.j2", form_bonus=form_bonus, form_scodoc=form_scodoc, scu=scu, diff --git a/app/scodoc/html_sco_header.py b/app/scodoc/html_sco_header.py index 7098757c0e..e4d330a78c 100644 --- a/app/scodoc/html_sco_header.py +++ b/app/scodoc/html_sco_header.py @@ -274,7 +274,7 @@ def sco_header( H.append("""
""") # En attendant le replacement complet de cette fonction, # inclusion ici des messages flask - H.append(render_template("flashed_messages.html")) + H.append(render_template("flashed_messages.j2")) # # Barre menu semestre: H.append(formsemestre_page_title(formsemestre_id)) diff --git a/app/scodoc/html_sidebar.py b/app/scodoc/html_sidebar.py index a487fcf0c6..33132a0566 100644 --- a/app/scodoc/html_sidebar.py +++ b/app/scodoc/html_sidebar.py @@ -166,6 +166,6 @@ def sidebar(etudid: int = None): def sidebar_dept(): """Partie supérieure de la marge de gauche""" return render_template( - "sidebar_dept.html", + "sidebar_dept.j2", prefs=sco_preferences.SemPreferences(), ) diff --git a/app/scodoc/sco_archives_etud.py b/app/scodoc/sco_archives_etud.py index 799024db4d..2718921497 100644 --- a/app/scodoc/sco_archives_etud.py +++ b/app/scodoc/sco_archives_etud.py @@ -373,7 +373,7 @@ def etudarchive_import_files( filename_title="fichier_a_charger", ) return render_template( - "scolar/photos_import_files.html", + "scolar/photos_import_files.j2", page_title="Téléchargement de fichiers associés aux étudiants", ignored_zipfiles=ignored_zipfiles, unmatched_files=unmatched_files, diff --git a/app/scodoc/sco_bulletins.py b/app/scodoc/sco_bulletins.py index e47177d648..392a20bd26 100644 --- a/app/scodoc/sco_bulletins.py +++ b/app/scodoc/sco_bulletins.py @@ -926,7 +926,7 @@ def formsemestre_bulletinetud( _formsemestre_bulletinetud_header_html(etud, formsemestre, format, version), bulletin, render_template( - "bul_foot.html", + "bul_foot.j2", appreciations=None, # déjà affichées css_class="bul_classic_foot", etud=etud, @@ -1259,7 +1259,7 @@ def _formsemestre_bulletinetud_header_html( cssstyles=["css/radar_bulletin.css"], ), render_template( - "bul_head.html", + "bul_head.j2", etud=etud, format=format, formsemestre=formsemestre, diff --git a/app/scodoc/sco_edit_module.py b/app/scodoc/sco_edit_module.py index c8e6d0fdf9..c4b1624cdb 100644 --- a/app/scodoc/sco_edit_module.py +++ b/app/scodoc/sco_edit_module.py @@ -385,7 +385,7 @@ def module_edit( ), f"""

{title}

""", render_template( - "scodoc/help/modules.html", + "scodoc/help/modules.j2", is_apc=is_apc, semestre_id=semestre_id, formsemestres=FormSemestre.query.filter( @@ -396,6 +396,7 @@ def module_edit( .all() if not create else None, + create=create, ), ] if not unlocked: @@ -655,7 +656,8 @@ def module_edit( ( "numero", { - "size": 2, + "title": "Numéro", + "size": 4, "explanation": "numéro (1, 2, 3, 4, ...) pour ordre d'affichage", "type": "int", "default": default_num, diff --git a/app/scodoc/sco_evaluation_edit.py b/app/scodoc/sco_evaluation_edit.py index 900827d411..6c41851989 100644 --- a/app/scodoc/sco_evaluation_edit.py +++ b/app/scodoc/sco_evaluation_edit.py @@ -345,7 +345,7 @@ def evaluation_create_form( + "\n".join(H) + "\n" + tf[1] - + render_template("scodoc/help/evaluations.html", is_apc=is_apc) + + render_template("scodoc/help/evaluations.j2", is_apc=is_apc) + html_sco_header.sco_footer() ) elif tf[0] == -1: diff --git a/app/scodoc/sco_formsemestre_status.py b/app/scodoc/sco_formsemestre_status.py index c3ab969083..4022440803 100644 --- a/app/scodoc/sco_formsemestre_status.py +++ b/app/scodoc/sco_formsemestre_status.py @@ -541,7 +541,7 @@ def formsemestre_page_title(formsemestre_id=None): formsemestre = FormSemestre.query.get_or_404(formsemestre_id) h = render_template( - "formsemestre_page_title.html", + "formsemestre_page_title.j2", formsemestre=formsemestre, scu=scu, sem_menu_bar=formsemestre_status_menubar(formsemestre), diff --git a/app/scodoc/sco_groups_edit.py b/app/scodoc/sco_groups_edit.py index 3af2c963b1..5caba3beb3 100644 --- a/app/scodoc/sco_groups_edit.py +++ b/app/scodoc/sco_groups_edit.py @@ -46,7 +46,7 @@ def affect_groups(partition_id): raise AccessDenied("vous n'avez pas la permission de modifier les groupes") partition.formsemestre.setup_parcours_groups() return render_template( - "scolar/affect_groups.html", + "scolar/affect_groups.j2", sco_header=html_sco_header.sco_header( page_title="Affectation aux groupes", javascripts=["js/groupmgr.js"], diff --git a/app/scodoc/sco_placement.py b/app/scodoc/sco_placement.py index 0e0ec8444e..6ce07aa8c2 100644 --- a/app/scodoc/sco_placement.py +++ b/app/scodoc/sco_placement.py @@ -215,7 +215,7 @@ def placement_eval_selectetuds(evaluation_id): html_sco_header.sco_header(), sco_evaluations.evaluation_describe(evaluation_id=evaluation_id), "

Placement et émargement des étudiants

", - render_template("scodoc/forms/placement.html", form=form), + render_template("scodoc/forms/placement.j2", form=form), ] footer = html_sco_header.sco_footer() return "\n".join(htmls) + "

" + footer diff --git a/app/scodoc/sco_trombino.py b/app/scodoc/sco_trombino.py index cf725794a7..140d1634d1 100644 --- a/app/scodoc/sco_trombino.py +++ b/app/scodoc/sco_trombino.py @@ -554,7 +554,7 @@ def photos_import_files_form(group_ids=()): back_url=back_url, ) return render_template( - "scolar/photos_import_files.html", + "scolar/photos_import_files.j2", page_title="Téléchargement des photos des étudiants", ignored_zipfiles=ignored_zipfiles, unmatched_files=unmatched_files, diff --git a/app/templates/about.html b/app/templates/about.j2 similarity index 56% rename from app/templates/about.html rename to app/templates/about.j2 index 0b2eed3893..23dc1ce5b9 100644 --- a/app/templates/about.html +++ b/app/templates/about.j2 @@ -1,5 +1,5 @@ {# -*- mode: jinja-html -*- #} -{% extends 'base.html' %} +{% extends 'base.j2' %} {% import 'bootstrap/wtf.html' as wtf %} {% block app_content %} @@ -9,10 +9,10 @@

© Emmanuel Viennet 2021

Version {{ version }}

- -

ScoDoc est un logiciel libre écrit en -Python. -Information et documentation sur scodoc.org. + +

ScoDoc est un logiciel libre écrit en + Python. + Information et documentation sur scodoc.org.

Dernières évolutions

diff --git a/app/templates/auth/change_password.html b/app/templates/auth/change_password.j2 similarity index 57% rename from app/templates/auth/change_password.html rename to app/templates/auth/change_password.j2 index 11e8448116..5f0dbe002e 100644 --- a/app/templates/auth/change_password.html +++ b/app/templates/auth/change_password.j2 @@ -1,14 +1,14 @@ {# -*- mode: jinja-html -*- #} -{% extends "base.html" %} +{% extends "base.j2" %} {% import 'bootstrap/wtf.html' as wtf %} {% macro render_field(field, auth_name=None) %} - {% if auth_name %} - {{ field.label }} ({{ auth_name }}): + {% if auth_name %} + {{ field.label }} ({{ auth_name }}): {% else %} - {{ field.label }} - {% endif %} + {{ field.label }} + {% endif %} {{ field(**kwargs)|safe }} {% if field.errors %}