From dc242c2e57f2abbacee5231ee320f9a12561326d Mon Sep 17 00:00:00 2001 From: root Date: Fri, 21 Aug 2026 12:18:49 +0000 Subject: [PATCH] =?UTF-8?q?Corriger=20le=20contexte=20fictif=20des=20aper?= =?UTF-8?q?=C3=A7us?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app_new/core/routes/admin.py | 9 +++++++-- .../test_intervention_location_and_template_audit.py | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app_new/core/routes/admin.py b/app_new/core/routes/admin.py index 1fd7ff1..bb5d50b 100644 --- a/app_new/core/routes/admin.py +++ b/app_new/core/routes/admin.py @@ -485,9 +485,14 @@ def template_debug_preview(): if demo_mode: from types import SimpleNamespace + class DemoValue(str): + """Valeur vide pouvant aussi être appelée par un template.""" + def __call__(self, *args, **kwargs): + return False + class DemoObject(SimpleNamespace): def __getattr__(self, name): - return '' + return DemoValue('') demo_room = DemoObject(id=12, name='B102', code='B102', full_name='Bâtiment principal — Zone Anglais — B102') demo_equipment = DemoObject( @@ -496,7 +501,7 @@ def template_debug_preview(): room=demo_room, status='en_service', status_label='En service', ) preview_context.update({ - 'current_user': DemoObject(id=1, username='demo.admin', full_name='Administrateur démo', role='admin', role_label='Administrateur système', is_authenticated=True), + 'current_user': DemoObject(id=1, username='demo.admin', full_name='Administrateur démo', role='admin', role_label='Administrateur système', is_authenticated=True, is_admin=lambda: True), 'stats': DemoObject(alerts_unread=3, interventions_pending=4, equipments=128), 'unread': 3, 'alerts': [DemoObject(id=1, title='Luminaire défaillant', message='Une intervention est à traiter.', level='warning')], diff --git a/tests/integration/test_intervention_location_and_template_audit.py b/tests/integration/test_intervention_location_and_template_audit.py index 9e2e839..ac85bb4 100644 --- a/tests/integration/test_intervention_location_and_template_audit.py +++ b/tests/integration/test_intervention_location_and_template_audit.py @@ -16,6 +16,10 @@ def test_template_audit_can_mark_and_restore_without_deleting(authenticated_clie assert 'sandbox' in response.get_data(as_text=True) assert 'Données fictives actives' in response.get_data(as_text=True) + chatbot_preview = authenticated_client.get('/admin/debug/templates/preview?path=chatbot%2Ftemplates%2Findex.html&demo=1') + assert chatbot_preview.status_code == 200 + assert 'Rendu incomplet' not in chatbot_preview.get_data(as_text=True) + response = authenticated_client.post('/admin/debug/templates/mark', data={ 'path': template_path, 'action': 'obsolete',