Skip to content
Snippets Groups Projects
Commit e1e7af58 authored by jarmil's avatar jarmil Committed by jan.bednarik
Browse files

Stranka MS - aktuality: strankovani

parent a233d2f0
No related branches found
No related tags found
2 merge requests!173Release,!134Weby pro MS
from django.core.paginator import Paginator
from django.db import models
from django.utils.translation import gettext_lazy
from wagtail.admin.edit_handlers import FieldPanel, MultiFieldPanel, StreamFieldPanel
......@@ -89,10 +90,8 @@ class DistrictArticles(MetadataPageMixin, Page):
def get_context(self, request):
context = super().get_context(request)
context["articles"] = (
self.get_siblings(inclusive=False)
.type(Article)
.live()
.specific()[: self.max_items]
)
context["articles"] = Paginator(
self.get_siblings(inclusive=False).type(Article).live().specific(),
self.max_items or 5,
).get_page(request.GET.get("page"))
return context
......@@ -11,5 +11,39 @@
{% endfor %}
</div>
<div class="pagination-container" role="navigation" aria-label="Pagination">
<nav>
{% if articles.has_previous %}
<a href="/aktuality/?page={{ articles.previous_page_number }}" class="btn btn--icon btn--grey-125 btn--hoveractive btn--to-black btn--condensed btn--inverted-icon px-0" aria-label="Předchozí stránka">
<div class="btn__body-wrap">
<div class="btn__body ">Předchozí</div>
<div class="btn__icon ">
<i class="ico--chevron-left"></i>
</div>
</div>
</a>
{% endif %}
{% for i in articles.paginator.page_range %}
<a href="/aktuality/?page={{ i }}" class="btn {% if i == articles.number %} btn--grey-500 {% else %} btn--grey-125 {% endif %} btn--hoveractive btn--to-black btn--condensed hidden md:inline-block px-0" aria-label="Stránka {{ i }}">
<div class="btn__body ">{{ i }}</div>
</a>
{% endfor %}
{% if articles.has_next %}
<a href="/aktuality/?page={{ articles.next_page_number }}" class="btn btn--icon btn--grey-125 btn--hoveractive btn--to-black btn--condensed px-0" aria-label="Další stránka">
<div class="btn__body-wrap">
<div class="btn__body ">Další</div>
<div class="btn__icon ">
<i class="ico--chevron-right"></i>
</div>
</div>
</a>
{% endif %}
</nav>
</div>
</main>
{% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment