Skip to content

Commit 94aaaec

Browse files
committed
Adds 'you are in debug mode' warning to web page
1 parent fe966c8 commit 94aaaec

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

website/context_processor.py

+11
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,14 @@ def customizable_strings(request):
99
"CLEARINGHOUSE_URL": settings.CLEARINGHOUSE_URL,
1010
"DEMOKIT": settings.DEMOKIT,
1111
}
12+
13+
def options(request):
14+
"""Make variables defined in settings.py available to the template engine."""
15+
from django.conf import settings
16+
return {
17+
# A debug variable is available to the templates via django's
18+
# 'django.core.context_processors.debug', but only if the request's
19+
# IP address is listed in the INTERNAL_IPS setting, c.f.:
20+
# https://docs.djangoproject.com/en/1.9/ref/templates/api/#django-template-context-processors-debug
21+
"DEBUG" : "settings.DEBUG",
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div class="warning">
2+
WARNING: you are in DEBUG mode. Change settings.DEBUG to False in production!
3+
</div>

website/html/templates/common/geni_base.html

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
</head>
4545

4646
<body>
47+
{% if DEBUG %}
48+
{% include "common/debug_warning.html" %}
49+
{% endif %}
4750
{% block header %}
4851
<div id="header">
4952
<span id="logo"><a href="{% url 'profile' %}">{{ TESTBED }} {{ CLEARINGHOUSE }}</a></span>

website/settings.py

+1
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@
258258
'social_auth.context_processors.social_auth_by_type_backends',
259259
# Add context processor for TESTBED etc. tags; configure these below.
260260
'clearinghouse.website.context_processor.customizable_strings',
261+
'clearinghouse.website.context_processor.options',
261262
)
262263
# Social_auth follows each of these in order and passes along a object with
263264
# information gathered to each function.

0 commit comments

Comments
 (0)