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
No related merge requests found
from django.core.paginator import Paginator
from django.db import models from django.db import models
from django.utils.translation import gettext_lazy from django.utils.translation import gettext_lazy
from wagtail.admin.edit_handlers import FieldPanel, MultiFieldPanel, StreamFieldPanel from wagtail.admin.edit_handlers import FieldPanel, MultiFieldPanel, StreamFieldPanel
...@@ -89,10 +90,8 @@ class DistrictArticles(MetadataPageMixin, Page): ...@@ -89,10 +90,8 @@ class DistrictArticles(MetadataPageMixin, Page):
def get_context(self, request): def get_context(self, request):
context = super().get_context(request) context = super().get_context(request)
context["articles"] = ( context["articles"] = Paginator(
self.get_siblings(inclusive=False) self.get_siblings(inclusive=False).type(Article).live().specific(),
.type(Article) self.max_items or 5,
.live() ).get_page(request.GET.get("page"))
.specific()[: self.max_items]
)
return context return context
...@@ -11,5 +11,39 @@ ...@@ -11,5 +11,39 @@
{% endfor %} {% endfor %}
</div> </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> </main>
{% endblock %} {% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment