# HG changeset patch # User Brian Neal # Date 1449025111 21600 # Node ID a34daec7f936f406f91ffc889d6956978b661136 # Parent c6bd7308de497ccbac080b2fff99cba85e4b2990 Converting to ManifestStaticFilesStorage. Got rid of all occurrences of STATIC_URL from Python code. diff -r c6bd7308de49 -r a34daec7f936 bio/templatetags/bio_tags.py --- a/bio/templatetags/bio_tags.py Sat Nov 28 22:16:29 2015 -0600 +++ b/bio/templatetags/bio_tags.py Tue Dec 01 20:58:31 2015 -0600 @@ -3,7 +3,6 @@ """ from django import template from django.conf import settings -from django.core.cache import cache from django.db.models import Count import bio.flags @@ -92,14 +91,14 @@ try: name = bio.flags.FLAG_DATA[code] except KeyError: - code = 'zz' - name = '' + src = None + else: + n = '24' if size == 'small' else '64' + src = "flags/{n}/{code}.png".format(n=n, code=code) return { - 'code': code, + 'src': src, 'name': name, - 'size': size, - 'STATIC_URL': settings.STATIC_URL, } @@ -111,9 +110,10 @@ annotate(count=Count('country')).order_by('country') for rec in flag_data: - rec['name'] = bio.flags.FLAG_DATA[rec['country']] + country = rec['country'] + rec['name'] = bio.flags.FLAG_DATA[country] + rec['src'] = "flags/24/{}.png".format(country) return { 'flag_data': flag_data, - 'STATIC_URL': settings.STATIC_URL, } diff -r c6bd7308de49 -r a34daec7f936 bio/templatetags/elsewhere_tags.py --- a/bio/templatetags/elsewhere_tags.py Sat Nov 28 22:16:29 2015 -0600 +++ b/bio/templatetags/elsewhere_tags.py Tue Dec 01 20:58:31 2015 -0600 @@ -2,7 +2,6 @@ Template tags for the elsewhere application. """ from django import template -from django.conf import settings register = template.Library() @@ -13,5 +12,4 @@ 'social_nets': user.social_network_profiles.all(), 'ims': user.instant_messenger_profiles.all(), 'websites': user.website_profiles.all(), - 'STATIC_URL': settings.STATIC_URL, } diff -r c6bd7308de49 -r a34daec7f936 comments/templatetags/comment_tags.py --- a/comments/templatetags/comment_tags.py Sat Nov 28 22:16:29 2015 -0600 +++ b/comments/templatetags/comment_tags.py Tue Dec 01 20:58:31 2015 -0600 @@ -8,7 +8,6 @@ {% render_comment_list [object] %} """ from django import template -from django.conf import settings from django.template.loader import render_to_string from comments.models import Comment @@ -163,6 +162,5 @@ qs = Comment.objects.for_object(object).select_related('user', 'user__profile') return { 'comments': qs, - 'STATIC_URL': settings.STATIC_URL, } diff -r c6bd7308de49 -r a34daec7f936 core/templatetags/core_tags.py --- a/core/templatetags/core_tags.py Sat Nov 28 22:16:29 2015 -0600 +++ b/core/templatetags/core_tags.py Tue Dec 01 20:58:31 2015 -0600 @@ -21,21 +21,15 @@ register = template.Library() -ICON_PARAMS = { - True: (settings.STATIC_URL + 'icons/accept.png', 'Yes'), - False: (settings.STATIC_URL + 'icons/delete.png', 'No'), -} -@register.simple_tag +@register.inclusion_tag('core/bool_icon.html') def bool_icon(flag): - params = ICON_PARAMS[bool(flag)] - return u"""%s""" % ( - params[0], params[1], params[1]) + return {'flag': flag} @register.inclusion_tag('core/comment_dialogs.html') def comment_dialogs(): - return {'STATIC_URL': settings.STATIC_URL} + return {} @register.inclusion_tag('core/max_users_tag.html') @@ -79,7 +73,6 @@ return { 'title': title, 'url': url, - 'STATIC_URL': settings.STATIC_URL, } @@ -182,7 +175,6 @@ birthdays.sort(key=lambda b: b.day) return { - 'STATIC_URL': settings.STATIC_URL, 'birthdays': birthdays, 'today': today, } diff -r c6bd7308de49 -r a34daec7f936 core/templatetags/script_tags.py --- a/core/templatetags/script_tags.py Sat Nov 28 22:16:29 2015 -0600 +++ b/core/templatetags/script_tags.py Tue Dec 01 20:58:31 2015 -0600 @@ -6,22 +6,22 @@ register = template.Library() -@register.simple_tag +@register.inclusion_tag('core/script_tags.html') def script_tags(libraries): - s = '' + css = [] + js = [] for library in libraries.split(): if library in settings.GPP_THIRD_PARTY_CSS: for path in settings.GPP_THIRD_PARTY_CSS[library]: - prefix = '' - if not path.startswith('http'): - prefix = settings.STATIC_URL - s += '' % (prefix, path) + local = not path.startswith('http') + css.append((local, path)) if library in settings.GPP_THIRD_PARTY_JS: for path in settings.GPP_THIRD_PARTY_JS[library]: - prefix = '' - if not path.startswith('http'): - prefix = settings.STATIC_URL - s += '' % (prefix, path) + local = not path.startswith('http') + js.append((local, path)) - return s + return { + 'css_sources': css, + 'js_sources': js, + } diff -r c6bd7308de49 -r a34daec7f936 forums/templatetags/forum_tags.py --- a/forums/templatetags/forum_tags.py Sat Nov 28 22:16:29 2015 -0600 +++ b/forums/templatetags/forum_tags.py Tue Dec 01 20:58:31 2015 -0600 @@ -37,7 +37,6 @@ def last_post_info(context, post): return { 'post': post, - 'STATIC_URL': context['STATIC_URL'], 'user': context['user'], } @@ -53,7 +52,6 @@ return { 'post': post, 'show_button': show_button, - 'STATIC_URL': settings.STATIC_URL, } @@ -122,7 +120,6 @@ 'form': form, 'submit_value': submit_value, 'is_ajax': is_ajax, - 'STATIC_URL': settings.STATIC_URL, } @@ -155,7 +152,6 @@ """Displays the "unread", "sticky", and "locked" icons for a given topic.""" return { 'topic': topic, - 'STATIC_URL': settings.STATIC_URL, } @@ -194,4 +190,4 @@ if subtitle: nav_list.append(dict(name=subtitle, url=None)) - return dict(nav_list=nav_list, STATIC_URL=settings.STATIC_URL) + return dict(nav_list=nav_list) diff -r c6bd7308de49 -r a34daec7f936 news/templatetags/news_tags.py --- a/news/templatetags/news_tags.py Sat Nov 28 22:16:29 2015 -0600 +++ b/news/templatetags/news_tags.py Tue Dec 01 20:58:31 2015 -0600 @@ -4,7 +4,6 @@ import datetime from django import template -from django.conf import settings from news.models import Story from news.utils import attach_extra_attrs @@ -26,6 +25,5 @@ return { 'stories': stories, - 'STATIC_URL': settings.STATIC_URL, 'on_home': True, } diff -r c6bd7308de49 -r a34daec7f936 sg101/templates/bio/elsewhere_links.html --- a/sg101/templates/bio/elsewhere_links.html Sat Nov 28 22:16:29 2015 -0600 +++ b/sg101/templates/bio/elsewhere_links.html Tue Dec 01 20:58:31 2015 -0600 @@ -1,15 +1,20 @@ +{% load static from staticfiles %} {% if social_nets or ims or websites %} diff -r c6bd7308de49 -r a34daec7f936 sg101/templates/bio/flag_icon.html --- a/sg101/templates/bio/flag_icon.html Sat Nov 28 22:16:29 2015 -0600 +++ b/sg101/templates/bio/flag_icon.html Tue Dec 01 20:58:31 2015 -0600 @@ -1,10 +1,6 @@ -{% if code != 'zz' %} - {% if size == 'large' %} -
- {{ name }} - {{ name }} -
- {% else %} - {{ name }} - {% endif %} +{% load static from staticfiles %} +{% if src %} +
+ {{ name }} {{ name }} +
{% endif %} diff -r c6bd7308de49 -r a34daec7f936 sg101/templates/bio/member_flags_tag.html --- a/sg101/templates/bio/member_flags_tag.html Sat Nov 28 22:16:29 2015 -0600 +++ b/sg101/templates/bio/member_flags_tag.html Tue Dec 01 20:58:31 2015 -0600 @@ -1,7 +1,8 @@ +{% load static from staticfiles %} {% if flag_data %}
{% for rec in flag_data %} - {{ rec.name }} {% endfor %}
diff -r c6bd7308de49 -r a34daec7f936 sg101/templates/comments/comment.html --- a/sg101/templates/comments/comment.html Sat Nov 28 22:16:29 2015 -0600 +++ b/sg101/templates/comments/comment.html Tue Dec 01 20:58:31 2015 -0600 @@ -1,3 +1,4 @@ +{% load static from staticfiles %} {% load bio_tags %}
{{ forloop.counter }}.
@@ -15,7 +16,7 @@ {% if not comment.is_removed %} | - Flag + Flag {% endif %}
diff -r c6bd7308de49 -r a34daec7f936 sg101/templates/core/birthday_block.html --- a/sg101/templates/core/birthday_block.html Sat Nov 28 22:16:29 2015 -0600 +++ b/sg101/templates/core/birthday_block.html Tue Dec 01 20:58:31 2015 -0600 @@ -1,7 +1,8 @@ {% extends 'side_block.html' %} {% load bio_tags %} {% load humanize %} -{% block block_title %}Cake {{ today|date:"F" }} Birthdays Cake {% endblock %} +{% load static from staticfiles %} +{% block block_title %}Cake {{ today|date:"F" }} Birthdays Cake{% endblock %} {% block block_content %} {% if birthdays %}