From 256a0f43b77dbb818036a3320e903e8be02efa01 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 21 Aug 2026 10:40:58 +0000 Subject: [PATCH] Distinguer le template des interventions --- app_new/__init__.py | 13 +++++++++++++ app_new/interventions/crud.py | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app_new/__init__.py b/app_new/__init__.py index 6405581..f53b019 100644 --- a/app_new/__init__.py +++ b/app_new/__init__.py @@ -10,6 +10,7 @@ from flask_wtf.csrf import CSRFProtect from datetime import timedelta import os import json +from jinja2 import ChoiceLoader, FileSystemLoader, PrefixLoader # Extensions (définies dans extensions.py) from .extensions import db, login_manager, migrate, csrf @@ -39,6 +40,18 @@ def create_app(config_name='default'): instance_relative_config=True, template_folder=template_dir, static_folder=os.path.join(app_dir, 'static')) + + # Les modules historiques contiennent plusieurs templates portant le même + # nom (notamment ``detail.html``). Ce préfixe garantit que la fiche + # intervention charge toujours le template du bon module. + app.jinja_loader = ChoiceLoader([ + app.jinja_loader, + PrefixLoader({ + 'interventions_module': FileSystemLoader( + os.path.join(app_dir, 'interventions', 'templates') + ), + }), + ]) # Tolerer les slashs finaux dans les URLs app.url_map.strict_slashes = False diff --git a/app_new/interventions/crud.py b/app_new/interventions/crud.py index a5cf11e..21ff3e2 100644 --- a/app_new/interventions/crud.py +++ b/app_new/interventions/crud.py @@ -406,7 +406,7 @@ def detail(id): history = intervention.status_history.order_by(StatusChange.created_at.desc()).all() # Utiliser explicitement le template du module. Une ancienne copie globale # de ``interventions/detail.html`` est conservée pour compatibilité. - return render_template('detail.html', + return render_template('interventions_module/detail.html', intervention=intervention, statuses=INTERVENTION_STATUSES, transitions=transitions,