From 202a045f2ce6ca5275930579ae724b737b13f099 Mon Sep 17 00:00:00 2001 From: David Evans Date: Tue, 17 Sep 2013 10:34:00 +0100 Subject: [PATCH] Use `static` templatetag rather than `STATIC_URL` This allows us to use the CachedStaticFilesStorage which gives unique names for each version of a static file. --- feincms/admin/tree_editor.py | 7 ++++--- feincms/module/page/modeladmins.py | 9 +++++---- feincms/templates/admin/content/table/init.html | 4 ++-- feincms/templates/admin/feincms/_regions_js.html | 3 ++- feincms/templates/admin/feincms/fe_editor.html | 4 ++-- feincms/templates/admin/feincms/fe_tools.html | 8 ++++---- feincms/templates/admin/feincms/item_editor.html | 6 +++--- .../templates/admin/feincms/load-jquery.include | 7 ++++--- feincms/templates/admin/feincms/tree_editor.html | 14 +++++++------- 9 files changed, 33 insertions(+), 29 deletions(-) diff --git a/feincms/admin/tree_editor.py b/feincms/admin/tree_editor.py index 4346a4864..37510733a 100644 --- a/feincms/admin/tree_editor.py +++ b/feincms/admin/tree_editor.py @@ -5,11 +5,11 @@ import json import logging -from django.conf import settings as django_settings from django.contrib import admin from django.contrib.admin.views import main from django.contrib.admin.actions import delete_selected from django.db import router +from django.contrib.staticfiles.templatetags.staticfiles import static from django.db.models import Q from django.http import (HttpResponse, HttpResponseBadRequest, HttpResponseForbidden, HttpResponseNotFound, HttpResponseServerError) @@ -39,8 +39,9 @@ def django_boolean_icon(field_val, alt_text=None, title=None): title = 'title="%s" ' % title else: title = '' - return mark_safe(u'%s' % - (django_settings.STATIC_URL, BOOLEAN_MAPPING[field_val], alt_text, title)) + icon_url = static('feincms/img/icon-%s.gif' % BOOLEAN_MAPPING[field_val]) + return mark_safe(u'%s' % + (icon_url, alt_text, title)) def _build_tree_structure(cls): diff --git a/feincms/module/page/modeladmins.py b/feincms/module/page/modeladmins.py index f55f4039c..0c6099445 100644 --- a/feincms/module/page/modeladmins.py +++ b/feincms/module/page/modeladmins.py @@ -7,6 +7,7 @@ from django.conf import settings as django_settings from django.core.exceptions import PermissionDenied from django.contrib.contenttypes.models import ContentType +from django.contrib.staticfiles.templatetags.staticfiles import static from django.contrib import admin from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect @@ -114,22 +115,22 @@ def _actions_column(self, page): actions.insert( 0, u'' - u'%s' + u'%s' u'' % ( page.pk, _('Add child page'), - django_settings.STATIC_URL, + static('feincms/img/icon_addlink.gif'), _('Add child page'), ) ) actions.insert( 0, u'' - u'%s' + u'%s' u'' % ( preview_url, _('View on site'), - django_settings.STATIC_URL, + static('feincms/img/selector-search.gif'), _('View on site'), ) ) diff --git a/feincms/templates/admin/content/table/init.html b/feincms/templates/admin/content/table/init.html index ab427dd1c..1f4b263e1 100644 --- a/feincms/templates/admin/content/table/init.html +++ b/feincms/templates/admin/content/table/init.html @@ -1,5 +1,5 @@ -{% load i18n %} - +{% load i18n staticfiles %} + + {% include "admin/feincms/_messages_js.html" %} {% include "admin/feincms/_regions_js.html" %} diff --git a/feincms/templates/admin/feincms/fe_tools.html b/feincms/templates/admin/feincms/fe_tools.html index 48ea3a1fe..c2b2f920c 100644 --- a/feincms/templates/admin/feincms/fe_tools.html +++ b/feincms/templates/admin/feincms/fe_tools.html @@ -1,11 +1,11 @@ -{% load i18n %} +{% load i18n staticfiles %} {% load url from future %} - - + +
{% trans "Stop Editing" %} diff --git a/feincms/templates/admin/feincms/item_editor.html b/feincms/templates/admin/feincms/item_editor.html index d21458a3c..15a24bbb5 100644 --- a/feincms/templates/admin/feincms/item_editor.html +++ b/feincms/templates/admin/feincms/item_editor.html @@ -1,13 +1,13 @@ {% extends "admin/change_form.html" %} -{% load i18n admin_modify %} +{% load i18n admin_modify staticfiles %} {% block extrahead %}{{ block.super }} {% block feincms_jquery_ui %} {% include "admin/feincms/load-jquery.include" %} {% endblock %} - - + + {% include "admin/feincms/_messages_js.html" %} {% include "admin/feincms/_regions_js.html" %} diff --git a/feincms/templates/admin/feincms/load-jquery.include b/feincms/templates/admin/feincms/load-jquery.include index 9926abfa8..62dd22b53 100644 --- a/feincms/templates/admin/feincms/load-jquery.include +++ b/feincms/templates/admin/feincms/load-jquery.include @@ -1,11 +1,12 @@ +{% load staticfiles %} {% comment %} Include jquery, override this template if you want to use a cdn version or load more plugins or whatnot {% endcomment %} - - - + + + - - - - + + + + {% endblock %}