[Patchew-devel] [PATCH 1/1] debug: Enable debug toolbar for superuser in production deploy

Fam Zheng famz at redhat.com
Tue Oct 23 14:01:15 UTC 2018


Signed-off-by: Fam Zheng <famz at redhat.com>
---
 patchew/settings.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/patchew/settings.py b/patchew/settings.py
index 65a3b29..cea5187 100644
--- a/patchew/settings.py
+++ b/patchew/settings.py
@@ -128,9 +128,8 @@ BLOB_DIR = os.path.join(DATA_DIR, "blob")
 if not os.path.isdir(BLOB_DIR):
     os.mkdir(BLOB_DIR)
 
-if DEBUG:
-    INSTALLED_APPS += ['debug_toolbar']
-    MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware']
+INSTALLED_APPS += ['debug_toolbar']
+MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware']
 
 MEDIA_ROOT = os.path.join(DATA_DIR, "media")
 MEDIA_URL = "/media/"
@@ -220,3 +219,10 @@ if not DEBUG:
             },
         },
     }
+
+def debug_toolbar_check(request):
+    return request.user.is_superuser
+
+DEBUG_TOOLBAR_CONFIG = {
+    'SHOW_TOOLBAR_CALLBACK': debug_toolbar_check,
+}
-- 
2.17.1




More information about the Patchew-devel mailing list