templates/list_pagination: add links to first and last pages

This commit is contained in:
Chris Tactic 2024-11-12 10:02:48 +01:00
parent cae5bdc1d8
commit 1df0aa7332

View File

@ -0,0 +1,45 @@
{% comment %}
Context:
- is_paginated: if True, page is paginated
- page_obj: page object from list view;
{% endcomment %}
{% load i18n aircox %}
{% if is_paginated %}
<hr/>
{% update_query request.GET.copy page=None as GET %}
{% with GET.urlencode as GET %}
<nav class="nav-urls is-centered" role="pagination" aria-label="{% translate "pagination" %}">
<ul class="urls">
{% if page_obj.has_previous %}
{% comment %}Translators: Bottom of the list, "previous page"{% endcomment %}
<a href="?{{ GET }}&page=1">&laquo; {% translate "first" %}</a>
<a href="?{{ GET }}&page={{ page_obj.previous_page_number }}" class="left"
title="{% translate "previous" %}"
aria-label="{% translate "previous" %}">
{% translate "previous" %}
</a>
{% endif %}
<span>
{{ page_obj.number }} / {{ page_obj.paginator.num_pages }}
</span>
{% if page_obj.has_next %}
{% comment %}Translators: Bottom of the list, "nextpage"{% endcomment %}
<a href="?{{ GET }}&page={{ page_obj.next_page_number }}" class="right"
title="{% translate "next" %}"
aria-label="{% translate "next" %}">
{% translate "next" %}
</a>
<a href="?{{ GET }}&page={{ page_obj.paginator.num_pages }}" class="right"
title="{% translate "last" %}"
aria-label="{% translate "last" %}">
{% translate "last" %} &raquo;
</a>
{% endif %}
</ul>
</nav>
{% endwith %}
{% endif %}