aboutsummaryrefslogtreecommitdiffstats
path: root/debug_toolbar
diff options
context:
space:
mode:
authorRob Hudson2008-09-09 14:48:36 -0700
committerRob Hudson2008-09-09 14:48:36 -0700
commit76a9d548f4f09cb1c54b0bc467a9a61c6d91fd96 (patch)
treec61a3bfb3f3878226851089ad36ceea46cc32430 /debug_toolbar
parentcba0d3712c17d8607f8e56901db392aa84ac8b40 (diff)
downloaddjango-debug-toolbar-76a9d548f4f09cb1c54b0bc467a9a61c6d91fd96.tar.bz2
Adding a `has_content` boolean to panels to avoid issues with checking if
content exists and displaying it in the templates.
Diffstat (limited to 'debug_toolbar')
-rw-r--r--debug_toolbar/panels/__init__.py1
-rw-r--r--debug_toolbar/panels/cache.py1
-rw-r--r--debug_toolbar/panels/headers.py1
-rw-r--r--debug_toolbar/panels/request_vars.py1
-rw-r--r--debug_toolbar/panels/sql.py1
-rw-r--r--debug_toolbar/templates/debug_toolbar/base.html18
6 files changed, 13 insertions, 10 deletions
diff --git a/debug_toolbar/panels/__init__.py b/debug_toolbar/panels/__init__.py
index c4a9f48..29cec02 100644
--- a/debug_toolbar/panels/__init__.py
+++ b/debug_toolbar/panels/__init__.py
@@ -5,6 +5,7 @@ class DebugPanel(object):
Base class for debug panels.
"""
# name = Base
+ has_content = False # If content returns something, set to true in subclass
def __init__(self, request):
self.request = request
diff --git a/debug_toolbar/panels/cache.py b/debug_toolbar/panels/cache.py
index fa6bdd0..263b62b 100644
--- a/debug_toolbar/panels/cache.py
+++ b/debug_toolbar/panels/cache.py
@@ -76,6 +76,7 @@ class CacheDebugPanel(DebugPanel):
Panel that displays the cache statistics.
"""
name = 'Cache'
+ has_content = True
def __init__(self, request):
# This is hackish but to prevent threading issues is somewhat needed
diff --git a/debug_toolbar/panels/headers.py b/debug_toolbar/panels/headers.py
index d75cb25..3ab4a95 100644
--- a/debug_toolbar/panels/headers.py
+++ b/debug_toolbar/panels/headers.py
@@ -6,6 +6,7 @@ class HeaderDebugPanel(DebugPanel):
A panel to display HTTP headers.
"""
name = 'Header'
+ has_content = True
# List of headers we want to display
header_filter = (
'CONTENT_TYPE',
diff --git a/debug_toolbar/panels/request_vars.py b/debug_toolbar/panels/request_vars.py
index 9f1a30d..a137393 100644
--- a/debug_toolbar/panels/request_vars.py
+++ b/debug_toolbar/panels/request_vars.py
@@ -6,6 +6,7 @@ class RequestVarsDebugPanel(DebugPanel):
A panel to display request variables (POST/GET, session, cookies).
"""
name = 'RequestVars'
+ has_content = True
def title(self):
return 'Request Vars'
diff --git a/debug_toolbar/panels/sql.py b/debug_toolbar/panels/sql.py
index 2ca50ed..0a95533 100644
--- a/debug_toolbar/panels/sql.py
+++ b/debug_toolbar/panels/sql.py
@@ -29,6 +29,7 @@ class SQLDebugPanel(DebugPanel):
Panel that displays information about the SQL queries run while processing the request.
"""
name = 'SQL'
+ has_content = True
def title(self):
total_time = sum(map(lambda q: float(q['time']) * 1000, connection.queries))
diff --git a/debug_toolbar/templates/debug_toolbar/base.html b/debug_toolbar/templates/debug_toolbar/base.html
index 7488b92..637e04d 100644
--- a/debug_toolbar/templates/debug_toolbar/base.html
+++ b/debug_toolbar/templates/debug_toolbar/base.html
@@ -41,7 +41,7 @@
<li id="djDebugButton">DEBUG</li>
{% for panel in panels %}
<li>
- {% if panel.content %}
+ {% if panel.has_content %}
<a href="{{ panel.url|default:"#" }}" onclick="djDebugToggle('{{ panel.dom_id }}')" title="{{ panel.title }}" class="{{ panel.dom_id }}">{{ panel.title }}</a>
{% else %}
{{ panel.title }}
@@ -51,15 +51,13 @@
</ul>
</div>
{% for panel in panels %}
- {% with panel.content as content %}
- {% if content %}
- <div id="{{ panel.dom_id }}" class="panelContent">
- <div class="title">
- <a href="" onclick="djDebugClose()" class="close">Close</a>
- </div>
- {{ content|safe }}
+ {% if panel.has_content %}
+ <div id="{{ panel.dom_id }}" class="panelContent">
+ <div class="title">
+ <a href="" onclick="djDebugClose()" class="close">Close</a>
</div>
- {% endif %}
- {% endwith %}
+ {{ panel.content|safe }}
+ </div>
+ {% endif %}
{% endfor %}
</div>