From 36547afb0b0531c34b00c125725e3a97d10b5e40 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 21 Jul 2024 07:49:58 +0200 Subject: [PATCH] make DEBUG flag available in templates. --- app/scodoc/sco_utils.py | 2 +- app/templates/sidebar.j2 | 3 +++ scodoc.py | 7 ++++++- tests/conftest.py | 7 ++++++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/scodoc/sco_utils.py b/app/scodoc/sco_utils.py index 7c558e3c8..90cb4365b 100644 --- a/app/scodoc/sco_utils.py +++ b/app/scodoc/sco_utils.py @@ -56,7 +56,7 @@ from pytz import timezone import flask from flask import g, request, Response -from flask import flash, url_for, make_response +from flask import flash, make_response from flask_json import json_response from werkzeug.http import HTTP_STATUS_CODES diff --git a/app/templates/sidebar.j2 b/app/templates/sidebar.j2 index f3ea3a126..19e1e0ca2 100755 --- a/app/templates/sidebar.j2 +++ b/app/templates/sidebar.j2 @@ -90,6 +90,9 @@ \ No newline at end of file diff --git a/scodoc.py b/scodoc.py index 8baf3cab0..ebe83a931 100755 --- a/scodoc.py +++ b/scodoc.py @@ -58,7 +58,12 @@ cli.register(app) def inject_sco_utils(): "Make Permission, sco and scu available in all Jinja templates" # if modified, put the same in conftest.py#27 - return {"Permission": Permission, "scu": scu, "sco": ScoData()} + return { + "DEBUG": flask.current_app.config["DEBUG"], + "Permission": Permission, + "scu": scu, + "sco": ScoData(), + } @app.shell_context_processor diff --git a/tests/conftest.py b/tests/conftest.py index 5d7a1e8ef..58ca1c111 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -29,7 +29,12 @@ def test_client(): @apptest.context_processor def inject_sco_utils(): "Make scu available in all Jinja templates" - return {"Permission": Permission, "scu": scu, "sco": ScoData()} + return { + "DEBUG": flask.current_app.config["DEBUG"], + "Permission": Permission, + "scu": scu, + "sco": ScoData(), + } with apptest.test_request_context(): # initialize scodoc "g":