From 76a9d548f4f09cb1c54b0bc467a9a61c6d91fd96 Mon Sep 17 00:00:00 2001 From: Rob Hudson Date: Tue, 9 Sep 2008 14:48:36 -0700 Subject: Adding a `has_content` boolean to panels to avoid issues with checking if content exists and displaying it in the templates. --- debug_toolbar/panels/__init__.py | 1 + debug_toolbar/panels/cache.py | 1 + debug_toolbar/panels/headers.py | 1 + debug_toolbar/panels/request_vars.py | 1 + debug_toolbar/panels/sql.py | 1 + debug_toolbar/templates/debug_toolbar/base.html | 18 ++++++++---------- 6 files changed, 13 insertions(+), 10 deletions(-) (limited to 'debug_toolbar') 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 @@