Corriger le contexte fictif des aperçus
Some checks are pending
CI - Tests et Syntax / lint-and-test (push) Waiting to run
Some checks are pending
CI - Tests et Syntax / lint-and-test (push) Waiting to run
This commit is contained in:
parent
b1f1e8b604
commit
dc242c2e57
2 changed files with 11 additions and 2 deletions
|
|
@ -485,9 +485,14 @@ def template_debug_preview():
|
||||||
if demo_mode:
|
if demo_mode:
|
||||||
from types import SimpleNamespace
|
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):
|
class DemoObject(SimpleNamespace):
|
||||||
def __getattr__(self, name):
|
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_room = DemoObject(id=12, name='B102', code='B102', full_name='Bâtiment principal — Zone Anglais — B102')
|
||||||
demo_equipment = DemoObject(
|
demo_equipment = DemoObject(
|
||||||
|
|
@ -496,7 +501,7 @@ def template_debug_preview():
|
||||||
room=demo_room, status='en_service', status_label='En service',
|
room=demo_room, status='en_service', status_label='En service',
|
||||||
)
|
)
|
||||||
preview_context.update({
|
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),
|
'stats': DemoObject(alerts_unread=3, interventions_pending=4, equipments=128),
|
||||||
'unread': 3,
|
'unread': 3,
|
||||||
'alerts': [DemoObject(id=1, title='Luminaire défaillant', message='Une intervention est à traiter.', level='warning')],
|
'alerts': [DemoObject(id=1, title='Luminaire défaillant', message='Une intervention est à traiter.', level='warning')],
|
||||||
|
|
|
||||||
|
|
@ -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 'sandbox' in response.get_data(as_text=True)
|
||||||
assert 'Données fictives actives' 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={
|
response = authenticated_client.post('/admin/debug/templates/mark', data={
|
||||||
'path': template_path,
|
'path': template_path,
|
||||||
'action': 'obsolete',
|
'action': 'obsolete',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue