diff options
Diffstat (limited to 'debug_toolbar')
| -rw-r--r-- | debug_toolbar/middleware.py | 9 | ||||
| -rw-r--r-- | debug_toolbar/panels/__init__.py | 7 | ||||
| -rw-r--r-- | debug_toolbar/templates/debug_toolbar/base.html | 2 |
3 files changed, 11 insertions, 7 deletions
diff --git a/debug_toolbar/middleware.py b/debug_toolbar/middleware.py index 7988fd5..4f5b9bd 100644 --- a/debug_toolbar/middleware.py +++ b/debug_toolbar/middleware.py @@ -92,9 +92,8 @@ class DebugToolbarMiddleware(object): toolbar = DebugToolbar(request) for panel in toolbar.panels: - panel.disabled = panel.dom_id() in request.COOKIES - panel.enabled = not panel.disabled - if panel.disabled: + panel.enabled = panel.dom_id() not in request.COOKIES + if not panel.enabled: continue panel.process_request(request) self.__class__.debug_toolbars[threading.current_thread().ident] = toolbar @@ -106,7 +105,7 @@ class DebugToolbarMiddleware(object): return result = None for panel in toolbar.panels: - if panel.disabled: + if not panel.enabled: continue response = panel.process_view(request, view_func, view_args, view_kwargs) if response: @@ -134,7 +133,7 @@ class DebugToolbarMiddleware(object): if ('gzip' not in response.get('Content-Encoding', '') and response.get('Content-Type', '').split(';')[0] in _HTML_TYPES): for panel in toolbar.panels: - if panel.disabled: + if not panel.enabled: continue panel.process_response(request, response) response.content = replace_insensitive( diff --git a/debug_toolbar/panels/__init__.py b/debug_toolbar/panels/__init__.py index eb3b21f..d4a61da 100644 --- a/debug_toolbar/panels/__init__.py +++ b/debug_toolbar/panels/__init__.py @@ -10,7 +10,12 @@ class DebugPanel(object): """ # name = 'Base' # template = 'debug_toolbar/panels/base.html' - has_content = False # If content returns something, set to True in subclass + + # If content returns something, set to True in subclass + has_content = False + + # This can be set to False in instances if the panel is disabled. + enabled = True # We'll maintain a local context instance so we can expose our template # context variables to panels which need them: diff --git a/debug_toolbar/templates/debug_toolbar/base.html b/debug_toolbar/templates/debug_toolbar/base.html index d5a356c..6162020 100644 --- a/debug_toolbar/templates/debug_toolbar/base.html +++ b/debug_toolbar/templates/debug_toolbar/base.html @@ -24,7 +24,7 @@ if(!window.jQuery) document.write('<scr'+'ipt src="{{ STATIC_URL }}debug_toolbar {% if panel.has_content and panel.enabled %} <a href="{{ panel.url|default:"#" }}" title="{{ panel.title }}" class="{{ panel.dom_id }}"> {% else %} - <div class="contentless{% if panel.disabled %} disabled{% endif %}"> + <div class="contentless{% if not panel.enabled %} disabled{% endif %}"> {% endif %} {{ panel.nav_title }} {% if panel.enabled %} |
