Ensure all listing pages have pagination controls and feed links
This commit is contained in:
parent
e19a2456e7
commit
d83e3e0afe
4 changed files with 28 additions and 25 deletions
|
@ -1,15 +1,4 @@
|
|||
{% extends "common/content_page.html" %}
|
||||
|
||||
{% load wagtailroutablepage_tags %}
|
||||
|
||||
{% block extra_css %}
|
||||
<link rel="alternate" type="application/rss+xml" href="{% routablepageurl page 'feed' %}">
|
||||
{% endblock %}
|
||||
|
||||
{% block hero_buttons %}
|
||||
<a class="button is-radiusless" href="{% routablepageurl page 'feed' %}" title="View feed"><i class="fas fa-rss" aria-hidden="true"></i></a>
|
||||
{{ block.super }}
|
||||
{% endblock %}
|
||||
{% extends "common/listing_page.html" %}
|
||||
|
||||
{% block post_content %}
|
||||
<section class="container">
|
||||
|
|
|
@ -2,14 +2,27 @@
|
|||
|
||||
{% load wagtailroutablepage_tags %}
|
||||
|
||||
{% block extra_css %}
|
||||
{% block extra_head %}
|
||||
{{ block.super }}
|
||||
<link rel="alternate" type="application/rss+xml" href="{% routablepageurl page 'feed' %}">
|
||||
{% endblock %}
|
||||
|
||||
{% block hero_buttons %}
|
||||
<a class="button is-radiusless" href="{% routablepageurl page 'feed' %}" title="View feed"><i class="fas fa-rss" aria-hidden="true"></i></a>
|
||||
{{ block.super }}
|
||||
{% endblock %}
|
||||
|
||||
{% block post_content %}
|
||||
<section class="container">
|
||||
{% for page in listing_pages %}
|
||||
{% include "common/listing-item.html" %}
|
||||
{% endfor %}
|
||||
</section>
|
||||
|
||||
{% if listing_pages.has_other_pages %}
|
||||
<section class="container">
|
||||
<hr class="my-5" />
|
||||
{% include "common/pagination.html" with page=listing_pages %}
|
||||
</section>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,33 +1,33 @@
|
|||
{% load wagtailadmin_tags %}
|
||||
|
||||
<nav class="pagination is-centered" role="navigation" aria-label="pagination">
|
||||
{% if pages.has_previous %}
|
||||
<a class="pagination-previous" href="{% querystring page=pages.previous_page_number %}">Previous</a>
|
||||
{% if page.has_previous %}
|
||||
<a class="pagination-previous" href="{% querystring page=page.previous_page_number %}">Previous</a>
|
||||
{% endif %}
|
||||
|
||||
{% if pages.has_next %}
|
||||
<a class="pagination-next" href="{% querystring page=pages.next_page_number %}">Next page</a>
|
||||
{% if page.has_next %}
|
||||
<a class="pagination-next" href="{% querystring page=page.next_page_number %}">Next page</a>
|
||||
{% endif %}
|
||||
|
||||
<ul class="pagination-list">
|
||||
{% if pages.has_previous and pages.previous_page_number != 1 %}
|
||||
{% if page.has_previous and page.previous_page_number != 1 %}
|
||||
<li><a class="pagination-link" aria-label="Goto page 1" href="{% querystring page=1 %}">1</a></li>
|
||||
<li><span class="pagination-ellipsis">…</span></li>
|
||||
{% endif %}
|
||||
|
||||
{% if pages.has_previous %}
|
||||
<li><a class="pagination-link" aria-label="Goto page {{ pages.previous_page_number }}" href="{% querystring page=pages.previous_page_number %}">{{ pages.previous_page_number }}</a></li>
|
||||
{% if page.has_previous %}
|
||||
<li><a class="pagination-link" aria-label="Goto page {{ page.previous_page_number }}" href="{% querystring page=page.previous_page_number %}">{{ page.previous_page_number }}</a></li>
|
||||
{% endif %}
|
||||
|
||||
<li><a class="pagination-link is-current" aria-label="Page {{ pages.number }}" aria-current="page">{{ pages.number }}</a></li>
|
||||
<li><a class="pagination-link is-current" aria-label="Page {{ page.number }}" aria-current="page">{{ page.number }}</a></li>
|
||||
|
||||
{% if pages.has_next %}
|
||||
<li><a class="pagination-link" aria-label="Goto page {{ pages.next_page_number }}" href="{% querystring page=pages.next_page_number %}">{{ pages.next_page_number }}</a></li>
|
||||
{% if page.has_next %}
|
||||
<li><a class="pagination-link" aria-label="Goto page {{ page.next_page_number }}" href="{% querystring page=page.next_page_number %}">{{ page.next_page_number }}</a></li>
|
||||
{% endif %}
|
||||
|
||||
{% if pages.has_next and pages.next_page_number != pages.paginator.num_pages %}
|
||||
{% if page.has_next and page.next_page_number != page.paginator.num_pages %}
|
||||
<li><span class="pagination-ellipsis">…</span></li>
|
||||
<li><a class="pagination-link" aria-label="Goto page {{ pages.paginator.num_pages }}" href="{% querystring page=pages.paginator.num_pages %}">{{ pages.paginator.num_pages }}</a></li>
|
||||
<li><a class="pagination-link" aria-label="Goto page {{ page.paginator.num_pages }}" href="{% querystring page=page.paginator.num_pages %}">{{ page.paginator.num_pages }}</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</nav>
|
||||
|
|
|
@ -55,6 +55,7 @@ class ListingPageTestCase(TestCase):
|
|||
response = self.client.get(self.page.url)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(len(response.context["listing_pages"]), 2)
|
||||
self.assertContains(response, self.page.reverse_subpage("feed"))
|
||||
|
||||
def test_feed_accessible(self) -> None:
|
||||
response = self.client.get(self.page.url + self.page.reverse_subpage("feed"))
|
||||
|
|
Loading…
Reference in a new issue