]> git.parisson.com Git - teleforma.git/commitdiff
Add django-debug-toolbar in DEV
authortest test <yoanl@pilotsystems.net>
Mon, 31 May 2021 14:21:53 +0000 (16:21 +0200)
committerYoan Le Clanche <yoanl@pilotsystems.net>
Mon, 31 May 2021 14:21:53 +0000 (16:21 +0200)
app/settings.py
app/urls.py
requirements-dev.txt

index 93d6d236cc53cc57d7920256fe4543551a65d4f7..45d4fad8e82b052aca8c97478d3cfc7100c188d2 100644 (file)
@@ -10,7 +10,8 @@ from django.urls import reverse_lazy
 
 sys.dont_write_bytecode = True
 
-DEBUG = True if os.environ.get('DEBUG') == 'True' else False
+DEBUG_ENV = os.environ.get('DEBUG') == 'True'
+DEBUG = DEBUG_ENV
 TEMPLATE_DEBUG = DEBUG
 
 
@@ -117,8 +118,7 @@ TEMPLATE_LOADERS = (
     )),
 )
 
-
-MIDDLEWARE = (
+MIDDLEWARE = (('debug_toolbar.middleware.DebugToolbarMiddleware',) if DEBUG_ENV else []) + (
     'django.middleware.common.CommonMiddleware',
     'django.contrib.sessions.middleware.SessionMiddleware',
     'django.middleware.csrf.CsrfViewMiddleware',
@@ -169,6 +169,9 @@ INSTALLED_APPS = (
 )
 
 
+if DEBUG_ENV:
+    INSTALLED_APPS += ('debug_toolbar',)
+
 TEMPLATES = [
     {
         'BACKEND': 'django.template.backends.django.DjangoTemplates',
@@ -217,6 +220,10 @@ EMAIL_HOST = 'localhost'
 DEFAULT_FROM_EMAIL = 'crfpa@pre-barreau.com'
 SERVER_EMAIL = 'crfpa@pre-barreau.com'
 EMAIL_SUBJECT_PREFIX = '[' + TELEMETA_ORGANIZATION + '] '
+if DEBUG_ENV:
+    EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
+
+
 
 POSTMAN_AUTO_MODERATE_AS = True
 POSTMAN_DISALLOW_ANONYMOUS = True
@@ -338,3 +345,10 @@ POSTMAN_SHOW_USER_AS = show_user_as
 #THUMBNAIL_FORCE_OVERWRITE = True
 
 ALLOWED_HOSTS = ['localhost', 'crfpa.dockdev.pilotsystems.net']
+
+if DEBUG_ENV:
+    def show_toolbar(request):
+        return True
+    DEBUG_TOOLBAR_CONFIG = {
+        "SHOW_TOOLBAR_CALLBACK" : show_toolbar,
+    }
index cf2e9873572f8077a6d50ebd2dcef8eab749e1c1..0c18e06b56d0f4fd8967446ab51afaef8ae90168 100644 (file)
@@ -1,13 +1,19 @@
 # -*- coding: utf-8 -*-
-from django.http import HttpResponse
+import os
+
+import debug_toolbar
 from django.conf.urls import include, url
-from django.views.i18n import JavaScriptCatalog
 # Uncomment the next two lines to enable the admin:
 from django.contrib import admin
+from django.http import HttpResponse
+from django.views.i18n import JavaScriptCatalog
+
 admin.autodiscover()
 
 js_info_dict = ['teleforma']
 
+DEBUG_ENV = os.environ.get('DEBUG') == 'True'
+
 urlpatterns = [
     # Example:
     # (r'^sandbox/', include('sandbox.foo.urls')),
@@ -31,4 +37,5 @@ urlpatterns = [
     url(r'^pdfannotator/', include('pdfannotator.urls')),
     url(r'^captcha/', include('captcha.urls')),
     url(r'^messages/', include('postman.urls', namespace='postman')),
-]
+] + ([url(r'^__debug__/', include(debug_toolbar.urls)),] if DEBUG_ENV else [])
+
index e496698c6439882b19dc71b9e8765feee58b7531..d1cc50e1cd1c9a385873ea96bfe0d7b6408fe92d 100644 (file)
@@ -1 +1,2 @@
 ipdb==0.13.8
+django-debug-toolbar
\ No newline at end of file