]> git.parisson.com Git - teleforma.git/commitdiff
use INTERNAL_IPS to detect debug mode in template, use DEBUG for the debug
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Fri, 12 Aug 2022 07:07:55 +0000 (09:07 +0200)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Fri, 12 Aug 2022 07:07:55 +0000 (09:07 +0200)
toolbar

app/settings.py
teleforma/templates/teleforma/base.html

index 996ccb0668893e6b83638cb043da272a1ac1a6b5..97f8ef63258666175f644b7e53d3da2e33b5b12d 100644 (file)
@@ -5,6 +5,7 @@ from django.utils.encoding import force_text
 import warnings
 import os
 import sys
+import socket
 from django.urls import reverse_lazy
 # import environ
 
@@ -16,10 +17,6 @@ TEMPLATE_DEBUG = DEBUG
 
 RECOVERY = False
 
-# disable to debug websocket and improve performance
-DEBUG_TOOLBAR = False
-
-
 BASE_DIR = os.path.dirname(os.path.dirname(__file__))
 
 warnings.showwarning = lambda *x: None
@@ -41,6 +38,13 @@ ALLOWED_HOSTS = ['localhost', 'crfpa.dockdev.pilotsystems.net',
 
 ASGI_APPLICATION = "teleforma.ws.routing.application"
 
+
+INTERNAL_IPS = ['127.0.0.1', ]
+
+# tricks to have debug toolbar when developing with docker
+ip = socket.gethostbyname(socket.gethostname())
+INTERNAL_IPS += [ip[:-1] + '1']
+
 REDIS_HOST = "redis"
 REDIS_PORT = 6379
 
@@ -159,7 +163,7 @@ TEMPLATE_LOADERS = (
     )),
 )
 
-MIDDLEWARE = (('debug_toolbar.middleware.DebugToolbarMiddleware',) if DEBUG_TOOLBAR else ()) + (
+MIDDLEWARE = (('debug_toolbar.middleware.DebugToolbarMiddleware',) if DEBUG else ()) + (
     'django.middleware.common.CommonMiddleware',
     'django.contrib.sessions.middleware.SessionMiddleware',
     'django.middleware.csrf.CsrfViewMiddleware',
@@ -200,7 +204,7 @@ INSTALLED_APPS = (
 )
 
 
-if DEBUG_TOOLBAR:
+if DEBUG:
     INSTALLED_APPS += ('debug_toolbar',)
 
 TEMPLATES = [
@@ -505,7 +509,7 @@ SHERLOKS_USE_TRANSACTION_ID = True
 
 ORAL_OPTION_PRICE = 250
 
-if DEBUG_TOOLBAR:
+if DEBUG:
     def show_toolbar(request):
         return True
     DEBUG_TOOLBAR_CONFIG = {
index fc6e34acbe8567551130fe9778c59ffbeb65b763..17709f54e6de7f97ad4094ea3090f3ebaf4b8614 100644 (file)
 
   {% block extra_javascript %}{% endblock %}
 
-  <script type="text/javascript" src="{% static 'teleforma/tarteaucitron/tarteaucitron.js' %}"></script>
+  {% if not debug %}
 
-  <script type="text/javascript">
-    tarteaucitron.init({
-      "privacyUrl": "/pages/legal_notices",
-      /* Privacy policy url */
+    <script type="text/javascript" src="{% static 'teleforma/tarteaucitron/tarteaucitron.js' %}"></script>
 
-      "hashtag": "#tarteaucitron",
-      /* Open the panel with this hashtag */
-      "cookieName": "tarteaucitron",
-      /* Cookie name */
+    <script type="text/javascript">
+      tarteaucitron.init({
+        "privacyUrl": "/pages/legal_notices",
+        /* Privacy policy url */
 
-      "orientation": "bottom",
-      /* Banner position (top - bottom) */
+        "hashtag": "#tarteaucitron",
+        /* Open the panel with this hashtag */
+        "cookieName": "tarteaucitron",
+        /* Cookie name */
 
-      "groupServices": false,
-      /* Group services by category */
+        "orientation": "bottom",
+        /* Banner position (top - bottom) */
 
-      "showAlertSmall": false,
-      /* Show the small banner on bottom right */
-      "cookieslist": false,
-      /* Show the cookie list */
+        "groupServices": false,
+        /* Group services by category */
 
-      "closePopup": false,
-      /* Show a close X on the banner */
+        "showAlertSmall": false,
+        /* Show the small banner on bottom right */
+        "cookieslist": false,
+        /* Show the cookie list */
 
-      "showIcon": false,
-      /* Show cookie icon to manage cookies */
-      //"iconSrc": "", /* Optionnal: URL or base64 encoded image */
-      "iconPosition": "BottomRight",
-      /* BottomRight, BottomLeft, TopRight and TopLeft */
+        "closePopup": false,
+        /* Show a close X on the banner */
 
-      "adblocker": false,
-      /* Show a Warning if an adblocker is detected */
+        "showIcon": false,
+        /* Show cookie icon to manage cookies */
+        //"iconSrc": "", /* Optionnal: URL or base64 encoded image */
+        "iconPosition": "BottomRight",
+        /* BottomRight, BottomLeft, TopRight and TopLeft */
 
-      "DenyAllCta": true,
-      /* Show the deny all button */
-      "AcceptAllCta": true,
-      /* Show the accept all button when highPrivacy on */
-      "highPrivacy": true,
-      /* HIGHLY RECOMMANDED Disable auto consent */
+        "adblocker": false,
+        /* Show a Warning if an adblocker is detected */
 
-      "handleBrowserDNTRequest": false,
-      /* If Do Not Track == 1, disallow all */
+        "DenyAllCta": true,
+        /* Show the deny all button */
+        "AcceptAllCta": true,
+        /* Show the accept all button when highPrivacy on */
+        "highPrivacy": true,
+        /* HIGHLY RECOMMANDED Disable auto consent */
 
-      "removeCredit": false,
-      /* Remove credit link */
-      "moreInfoLink": true,
-      /* Show more info link */
+        "handleBrowserDNTRequest": false,
+        /* If Do Not Track == 1, disallow all */
 
-      "useExternalCss": false,
-      /* If false, the tarteaucitron.css file will be loaded */
-      "useExternalJs": false,
-      /* If false, the tarteaucitron.js file will be loaded */
+        "removeCredit": false,
+        /* Remove credit link */
+        "moreInfoLink": true,
+        /* Show more info link */
 
-      //"cookieDomain": ".my-multisite-domaine.fr", /* Shared cookie for multisite */
+        "useExternalCss": false,
+        /* If false, the tarteaucitron.css file will be loaded */
+        "useExternalJs": false,
+        /* If false, the tarteaucitron.js file will be loaded */
 
-      "readmoreLink": "",
-      /* Change the default readmore link */
+        //"cookieDomain": ".my-multisite-domaine.fr", /* Shared cookie for multisite */
 
-      "mandatory": true,
-      /* Show a message about mandatory cookies */
-    });
-  </script>
+        "readmoreLink": "",
+        /* Change the default readmore link */
 
-  {% endblock %}
+        "mandatory": true,
+        /* Show a message about mandatory cookies */
+      });
+    </script>
+
+
+    <script type="text/javascript">
+      tarteaucitron.user.gajsUa = 'UA-6573030-11';
+      tarteaucitron.user.gajsMore = function () {};
+      (tarteaucitron.job = tarteaucitron.job || []).push('gajs');
+    </script>
+
+  {% endif %}
 
   <script type='text/javascript'>
     window.scrollTo(0, 1);
     });
   </script>
 
-  <script type="text/javascript">
-    tarteaucitron.user.gajsUa = 'UA-6573030-11';
-    tarteaucitron.user.gajsMore = function () {};
-    (tarteaucitron.job = tarteaucitron.job || []).push('gajs');
-  </script>
-
   {% webpack 'app.js' %}
+
+  {% endblock %}
+
 </body>
 
 </html>
\ No newline at end of file