diff --git a/cms/envs/devstack.py b/cms/envs/devstack.py index fe9d96972ba4..d6f871d0802f 100644 --- a/cms/envs/devstack.py +++ b/cms/envs/devstack.py @@ -54,7 +54,8 @@ ) DEBUG_TOOLBAR_CONFIG = { - 'INTERCEPT_REDIRECTS': False + 'INTERCEPT_REDIRECTS': False, + 'SHOW_TOOLBAR_CALLBACK': 'check_debug.should_show_debug_toolbar', } # To see stacktraces for MongoDB queries, set this to True. diff --git a/common/lib/check_debug.py b/common/lib/check_debug.py new file mode 100644 index 000000000000..f0c03e9bbfca --- /dev/null +++ b/common/lib/check_debug.py @@ -0,0 +1,14 @@ +""" +Function to check debug status. +""" +import os + +def should_show_debug_toolbar(request): + """ + Return True/False to determine whether to show the Django + Debug Toolbar. + + If HIDE_TOOLBAR is set in the process environment, the + toolbar will be hidden. + """ + return not bool(os.getenv('HIDE_TOOLBAR', '')) diff --git a/lms/envs/devstack.py b/lms/envs/devstack.py index 5f03e93c335c..5f15b48ecfd8 100644 --- a/lms/envs/devstack.py +++ b/lms/envs/devstack.py @@ -53,7 +53,7 @@ DEBUG_TOOLBAR_CONFIG = { 'INTERCEPT_REDIRECTS': False, - 'SHOW_TOOLBAR_CALLBACK': lambda _: True, + 'SHOW_TOOLBAR_CALLBACK': 'check_debug.should_show_debug_toolbar', } ########################### PIPELINE #################################