1
0
forked from ScoDoc/ScoDoc

make DEBUG flag available in templates.

This commit is contained in:
Emmanuel Viennet 2024-07-21 07:49:58 +02:00
parent 059678c3b3
commit 36547afb0b
4 changed files with 16 additions and 3 deletions

View File

@ -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

View File

@ -90,6 +90,9 @@
<div class="logo-logo">
<a href="{{ url_for( 'scodoc.about', scodoc_dept=g.scodoc_dept ) }}">
{{ scu.icontag("scologo_img", no_size=True) | safe}}</a>
{% if DEBUG %}
<div style="color:gold; background-color:navy;">DEBUG</div>
{% endif %}
</div>
</div>
<!-- end of sidebar -->

View File

@ -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

View File

@ -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":