Fix deprecated usage of register.assignment_tag

pull/2443/merge
Josh Schneier 2016-04-03 17:14:02 -04:00 zatwierdzone przez Matt Westcott
rodzic c428f92711
commit 0855f59500
4 zmienionych plików z 19 dodań i 5 usunięć

Wyświetl plik

@ -11,6 +11,7 @@ Changelog
* The type of the ``search_fields`` attribute on ``Page`` models (and other searchable models) has changed from a tuple to a list (Tim Heap) * The type of the ``search_fields`` attribute on ``Page`` models (and other searchable models) has changed from a tuple to a list (Tim Heap)
* Use `PasswordChangeForm` when user changes their password, requiring the user to enter their current password (Matthijs Melissen) * Use `PasswordChangeForm` when user changes their password, requiring the user to enter their current password (Matthijs Melissen)
* Highlight current day in date picker (Jonas Lergell) * Highlight current day in date picker (Jonas Lergell)
* Eliminated the deprecated `register.assignment_tag` on Django 1.9 (Josh Schneier)
* Fix: The currently selected day is now highlighted only in the correct month in date pickers (Jonas Lergell) * Fix: The currently selected day is now highlighted only in the correct month in date pickers (Jonas Lergell)
* Fix: Fixed crash when an image without a source file was resized with the "dynamic serve view" * Fix: Fixed crash when an image without a source file was resized with the "dynamic serve view"

Wyświetl plik

@ -31,6 +31,7 @@ Minor features
* The type of the ``search_fields`` attribute on ``Page`` models (and other searchable models) has changed from a tuple to a list (see upgrade consideration below) (Tim Heap) * The type of the ``search_fields`` attribute on ``Page`` models (and other searchable models) has changed from a tuple to a list (see upgrade consideration below) (Tim Heap)
* Use `PasswordChangeForm` when user changes their password, requiring the user to enter their current password (Matthijs Melissen) * Use `PasswordChangeForm` when user changes their password, requiring the user to enter their current password (Matthijs Melissen)
* Highlight current day in date picker (Jonas Lergell) * Highlight current day in date picker (Jonas Lergell)
* Eliminated the deprecated ``register.assignment_tag`` on Django 1.9 (Josh Schneier)
Bug fixes Bug fixes
~~~~~~~~~ ~~~~~~~~~

Wyświetl plik

@ -1,5 +1,6 @@
from __future__ import absolute_import, unicode_literals from __future__ import absolute_import, unicode_literals
import django
from django import template from django import template
from wagtail.contrib.wagtailsearchpromotions.models import SearchPromotion from wagtail.contrib.wagtailsearchpromotions.models import SearchPromotion
@ -7,8 +8,13 @@ from wagtail.wagtailsearch.models import Query
register = template.Library() register = template.Library()
if django.VERSION >= (1, 9):
assignment_tag = register.simple_tag
else:
assignment_tag = register.assignment_tag
@register.assignment_tag()
@assignment_tag
def get_search_promotions(search_query): def get_search_promotions(search_query):
if search_query: if search_query:
return Query.get(search_query).editors_picks.all() return Query.get(search_query).editors_picks.all()

Wyświetl plik

@ -2,6 +2,7 @@ from __future__ import absolute_import, unicode_literals
import itertools import itertools
import django
from django import template from django import template
from django.conf import settings from django.conf import settings
from django.contrib.humanize.templatetags.humanize import intcomma from django.contrib.humanize.templatetags.humanize import intcomma
@ -21,6 +22,11 @@ register = template.Library()
register.filter('intcomma', intcomma) register.filter('intcomma', intcomma)
if django.VERSION >= (1, 9):
assignment_tag = register.simple_tag
else:
assignment_tag = register.assignment_tag
@register.inclusion_tag('wagtailadmin/shared/explorer_nav.html') @register.inclusion_tag('wagtailadmin/shared/explorer_nav.html')
def explorer_nav(): def explorer_nav():
@ -93,7 +99,7 @@ def widgettype(bound_field):
return "" return ""
@register.assignment_tag(takes_context=True) @assignment_tag(takes_context=True)
def page_permissions(context, page): def page_permissions(context, page):
""" """
Usage: {% page_permissions page as page_perms %} Usage: {% page_permissions page as page_perms %}
@ -109,7 +115,7 @@ def page_permissions(context, page):
return context['user_page_permissions'].for_page(page) return context['user_page_permissions'].for_page(page)
@register.assignment_tag(takes_context=True) @assignment_tag(takes_context=True)
def test_page_is_public(context, page): def test_page_is_public(context, page):
""" """
Usage: {% test_page_is_public page as is_public %} Usage: {% test_page_is_public page as is_public %}
@ -143,12 +149,12 @@ def hook_output(hook_name):
return mark_safe(''.join(snippets)) return mark_safe(''.join(snippets))
@register.assignment_tag @assignment_tag
def usage_count_enabled(): def usage_count_enabled():
return getattr(settings, 'WAGTAIL_USAGE_COUNT_ENABLED', False) return getattr(settings, 'WAGTAIL_USAGE_COUNT_ENABLED', False)
@register.assignment_tag @assignment_tag
def base_url_setting(): def base_url_setting():
return getattr(settings, 'BASE_URL', None) return getattr(settings, 'BASE_URL', None)