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)
* 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)
* 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: 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)
* 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)
* Eliminated the deprecated ``register.assignment_tag`` on Django 1.9 (Josh Schneier)
Bug fixes
~~~~~~~~~

Wyświetl plik

@ -1,5 +1,6 @@
from __future__ import absolute_import, unicode_literals
import django
from django import template
from wagtail.contrib.wagtailsearchpromotions.models import SearchPromotion
@ -7,8 +8,13 @@ from wagtail.wagtailsearch.models import Query
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):
if search_query:
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 django
from django import template
from django.conf import settings
from django.contrib.humanize.templatetags.humanize import intcomma
@ -21,6 +22,11 @@ register = template.Library()
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')
def explorer_nav():
@ -93,7 +99,7 @@ def widgettype(bound_field):
return ""
@register.assignment_tag(takes_context=True)
@assignment_tag(takes_context=True)
def page_permissions(context, page):
"""
Usage: {% page_permissions page as page_perms %}
@ -109,7 +115,7 @@ def page_permissions(context, 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):
"""
Usage: {% test_page_is_public page as is_public %}
@ -143,12 +149,12 @@ def hook_output(hook_name):
return mark_safe(''.join(snippets))
@register.assignment_tag
@assignment_tag
def usage_count_enabled():
return getattr(settings, 'WAGTAIL_USAGE_COUNT_ENABLED', False)
@register.assignment_tag
@assignment_tag
def base_url_setting():
return getattr(settings, 'BASE_URL', None)