Browse Source

Merge pull request #1094 from rafalp/fix-debug-toolbar

Always display debug toolbar in dev project
Rafał Pitoń 6 years ago
parent
commit
88b3144319
2 changed files with 17 additions and 1 deletions
  1. 12 1
      misago/bin/misago-start-devproject.py
  2. 5 0
      misago/conf/debugtoolbar.py

+ 12 - 1
misago/bin/misago-start-devproject.py

@@ -36,7 +36,18 @@ def fill_in_settings(f):
         s = s.replace("'HOST': 'localhost',", "'HOST': os.environ.get('POSTGRES_HOST'),")
         s = s.replace("'HOST': 'localhost',", "'HOST': os.environ.get('POSTGRES_HOST'),")
 
 
         # Specify console backend for email
         # Specify console backend for email
-        s += "\nEMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'\n"
+        s += "\n# Set dev instance to send e-mails to console"
+        s += "\n"
+        s += "\nEMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'"
+        s += "\n"
+
+        # Tie Debug Toolbar visibility to env variable
+        s += "\n# Display debug toolbar if IN_MISAGO_DOCKER enviroment var is set to \"1\""
+        s += "\n"
+        s += "\nDEBUG_TOOLBAR_CONFIG = {"
+        s += "\n    'SHOW_TOOLBAR_CALLBACK': 'misago.conf.debugtoolbar.enable_debug_toolbar'"
+        s += "\n}"
+        s += "\n"
 
 
         # Empty the contents of STATICFILES_DIRS (STATICFILES_DIRS = [])
         # Empty the contents of STATICFILES_DIRS (STATICFILES_DIRS = [])
         pos = s.find('STATICFILES_DIRS')
         pos = s.find('STATICFILES_DIRS')

+ 5 - 0
misago/conf/debugtoolbar.py

@@ -0,0 +1,5 @@
+import os
+
+
+def enable_debug_toolbar(_):
+    return os.environ.get('IN_MISAGO_DOCKER', '').lower() == "1"