mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-04 05:24:45 +00:00
Add formal deprecation for is_ajax=1 on pagination_nav.html
Some third-party packages still use it, e.g. 7a74a1d317/wagtailmodelchooser/templates/wagtailmodelchooser/chooser/model_results.html
This commit is contained in:
parent
b3ed5cc1cc
commit
9ed662a343
2 changed files with 41 additions and 26 deletions
|
|
@ -1,30 +1,35 @@
|
|||
{% load i18n %}
|
||||
{% load wagtailadmin_tags %}
|
||||
|
||||
{% comment %}
|
||||
HACK: This template expects to be passed a 'linkurl' parameter, containing a URL name
|
||||
that can be reverse-resolved by the {% url %} tag with no further parameters.
|
||||
Views that have parameters in their URL can work around this by omitting linkurl,
|
||||
which will produce a final URL of the form "?q=123", implicitly preserving the current URL path.
|
||||
Using the {% url ... as ... %} form of the tag ensures that this fails silently,
|
||||
rather than throwing a NoReverseMatch exception.
|
||||
{% endcomment %}
|
||||
{% if linkurl %}
|
||||
{% url linkurl as url_to_use %}
|
||||
{% endif %}
|
||||
{% if is_ajax %}
|
||||
{% ajax_pagination_nav_deprecation_warning %}
|
||||
{% include "wagtailadmin/shared/ajax_pagination_nav.html" %}
|
||||
{% else %}
|
||||
{% comment %}
|
||||
HACK: This template expects to be passed a 'linkurl' parameter, containing a URL name
|
||||
that can be reverse-resolved by the {% url %} tag with no further parameters.
|
||||
Views that have parameters in their URL can work around this by omitting linkurl,
|
||||
which will produce a final URL of the form "?q=123", implicitly preserving the current URL path.
|
||||
Using the {% url ... as ... %} form of the tag ensures that this fails silently,
|
||||
rather than throwing a NoReverseMatch exception.
|
||||
{% endcomment %}
|
||||
{% if linkurl %}
|
||||
{% url linkurl as url_to_use %}
|
||||
{% endif %}
|
||||
|
||||
<div class="pagination">
|
||||
<p>{% blocktrans with page_num=items.number total_pages=items.paginator.num_pages %}Page {{ page_num }} of {{ total_pages }}.{% endblocktrans %}</p>
|
||||
<ul>
|
||||
<li class="prev">
|
||||
{% if items.has_previous %}
|
||||
<a href="{{ url_to_use }}{% querystring p=items.previous_page_number %}" class="icon icon-arrow-left">{% trans 'Previous' %}</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
<li class="next">
|
||||
{% if items.has_next %}
|
||||
<a href="{{ url_to_use }}{% querystring p=items.next_page_number %}" class="icon icon-arrow-right-after">{% trans 'Next' %}</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="pagination">
|
||||
<p>{% blocktrans with page_num=items.number total_pages=items.paginator.num_pages %}Page {{ page_num }} of {{ total_pages }}.{% endblocktrans %}</p>
|
||||
<ul>
|
||||
<li class="prev">
|
||||
{% if items.has_previous %}
|
||||
<a href="{{ url_to_use }}{% querystring p=items.previous_page_number %}" class="icon icon-arrow-left">{% trans 'Previous' %}</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
<li class="next">
|
||||
{% if items.has_next %}
|
||||
<a href="{{ url_to_use }}{% querystring p=items.next_page_number %}" class="icon icon-arrow-right-after">{% trans 'Next' %}</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import itertools
|
||||
from warnings import warn
|
||||
|
||||
from django import template
|
||||
from django.conf import settings
|
||||
|
|
@ -20,6 +21,7 @@ from wagtail.core.models import (
|
|||
from wagtail.core.utils import cautious_slugify as _cautious_slugify
|
||||
from wagtail.core.utils import camelcase_to_underscore, escape_script
|
||||
from wagtail.users.utils import get_gravatar_url
|
||||
from wagtail.utils.deprecation import RemovedInWagtail27Warning
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
|
@ -430,3 +432,11 @@ def avatar_url(user, size=50):
|
|||
return gravatar_url
|
||||
|
||||
return static('wagtailadmin/images/default-user-avatar.png')
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def ajax_pagination_nav_deprecation_warning():
|
||||
warn('Passing is_ajax=1 to wagtailadmin/shared/pagination_nav.html is deprecated. '
|
||||
'Use wagtailadmin/shared/ajax_pagination_nav.html instead',
|
||||
category=RemovedInWagtail27Warning)
|
||||
return ''
|
||||
|
|
|
|||
Loading…
Reference in a new issue