From 4225671177f9f65e873ddbab373e5968c2afa8fc Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 23 Dec 2013 12:43:49 +0100 Subject: Fix staticfiles panel to work with prefixed STATICFILES_DIRS. Closes #503 and #507. Many thanks to Alexander Clausen (@sk1p) for the inspiration for the patch. --- debug_toolbar/locale/en/LC_MESSAGES/django.po | 7 ++++++- debug_toolbar/panels/staticfiles.py | 7 +++++-- debug_toolbar/templates/debug_toolbar/panels/staticfiles.html | 4 ++-- 3 files changed, 13 insertions(+), 5 deletions(-) (limited to 'debug_toolbar') diff --git a/debug_toolbar/locale/en/LC_MESSAGES/django.po b/debug_toolbar/locale/en/LC_MESSAGES/django.po index 6102d0d..06237f7 100644 --- a/debug_toolbar/locale/en/LC_MESSAGES/django.po +++ b/debug_toolbar/locale/en/LC_MESSAGES/django.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Django Debug Toolbar\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-12-15 13:11+0100\n" +"POT-Creation-Date: 2013-12-23 12:40+0100\n" "PO-Revision-Date: 2012-03-31 20:10+0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -557,6 +557,11 @@ msgid_plural "Static file paths" msgstr[0] "" msgstr[1] "" +#: templates/debug_toolbar/panels/staticfiles.html:8 +#, python-format +msgid "(prefix %(prefix)s)" +msgstr "" + #: templates/debug_toolbar/panels/staticfiles.html:12 #: templates/debug_toolbar/panels/staticfiles.html:23 #: templates/debug_toolbar/panels/staticfiles.html:35 diff --git a/debug_toolbar/panels/staticfiles.py b/debug_toolbar/panels/staticfiles.py index f212f2b..efaf841 100644 --- a/debug_toolbar/panels/staticfiles.py +++ b/debug_toolbar/panels/staticfiles.py @@ -163,8 +163,11 @@ class StaticFilesPanel(panels.Panel): """ Returns a list of paths to inspect for additional static files """ - dirs = getattr(settings, 'STATICFILES_DIRS', ()) - return [normpath(d) for d in dirs] + dirs = [] + for finder in finders.get_finders(): + if isinstance(finder, finders.FileSystemFinder): + dirs.extend(finder.locations) + return [(prefix, normpath(dir)) for prefix, dir in dirs] def get_staticfiles_apps(self): """ diff --git a/debug_toolbar/templates/debug_toolbar/panels/staticfiles.html b/debug_toolbar/templates/debug_toolbar/panels/staticfiles.html index eb413b5..95c9ec8 100644 --- a/debug_toolbar/templates/debug_toolbar/panels/staticfiles.html +++ b/debug_toolbar/templates/debug_toolbar/panels/staticfiles.html @@ -4,8 +4,8 @@

{% blocktrans count staticfiles_dirs|length as dirs_count %}Static file path{% plural %}Static file paths{% endblocktrans %}

{% if staticfiles_dirs %}
    - {% for staticfiles_dir in staticfiles_dirs %} -
  1. {{ staticfiles_dir }}
  2. + {% for prefix, staticfiles_dir in staticfiles_dirs %} +
  3. {{ staticfiles_dir }}{% if prefix %} {% blocktrans %}(prefix {{ prefix }}){% endblocktrans %}{% endif %}
  4. {% endfor %}
{% else %} -- cgit v1.2.3