Pagination
This commit is contained in:
parent
afbfb16a35
commit
b332697aba
5 changed files with 39 additions and 10 deletions
|
@ -1,13 +1,13 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from django.db import models
|
||||
from django.utils import translation
|
||||
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
||||
|
||||
from wagtail.wagtailcore.models import Page, Orderable
|
||||
from wagtail.wagtailadmin.edit_handlers import FieldPanel
|
||||
from wagtail.wagtailcore.fields import RichTextField
|
||||
|
||||
from django.utils import translation
|
||||
|
||||
class Stream(models.Model):
|
||||
title = models.CharField(max_length=255)
|
||||
ident = models.CharField(max_length=255)
|
||||
|
@ -70,13 +70,21 @@ class FeedPage(Page):
|
|||
elif curlang in ['fr']:
|
||||
entries = entries.exclude(lang='de')
|
||||
# Order by most recent date first
|
||||
entries = entries.order_by('-published')
|
||||
return entries[:10]
|
||||
return entries.order_by('-published')
|
||||
|
||||
def get_context(self, request):
|
||||
# Update template context
|
||||
context = super(FeedPage, self).get_context(request)
|
||||
context['feedentries'] = self.feedentries
|
||||
|
||||
# Wrap with pagination
|
||||
paginator = Paginator(self.feedentries, 9)
|
||||
page = request.GET.get('page')
|
||||
try:
|
||||
feedentries = paginator.page(page)
|
||||
except (PageNotAnInteger, EmptyPage):
|
||||
feedentries = paginator.page(1)
|
||||
|
||||
context['feedentries'] = feedentries
|
||||
return context
|
||||
|
||||
class Meta:
|
||||
|
|
|
@ -19,9 +19,29 @@
|
|||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
<!-- Page body -->
|
||||
<section id="news" class="feedpage-body">
|
||||
<div class="container">
|
||||
|
||||
<!-- Pagination -->
|
||||
<center>
|
||||
<ul class="pagination">
|
||||
{% if feedentries.has_previous %}
|
||||
<li><a href="?page={{ feedentries.previous_page_number }}" title="Previous">
|
||||
<span class="glyphicon glyphicon-arrow-left" aria-hidden="true"></span></a></li>
|
||||
{% endif %}
|
||||
{% for page_num in feedentries.paginator.page_range %}
|
||||
<li {% if page_num == feedentries.number %}class="active"{% endif %}>
|
||||
<a href="?page={{ page_num }}">{{ page_num }}</a></li>
|
||||
{% endfor %}
|
||||
{% if feedentries.has_next %}
|
||||
<li><a href="?page={{ feedentries.next_page_number }}" title="Next">
|
||||
<span class="glyphicon glyphicon-arrow-right" aria-hidden="true"></span></a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</center>
|
||||
|
||||
<div class="row">
|
||||
{% for entry in feedentries %}
|
||||
<div class="col-md-4 col-sm-6 col-xs-12">
|
||||
|
|
|
@ -239,7 +239,7 @@ class HomePage(Page):
|
|||
entries = entries.exclude(lang='fr')
|
||||
elif curlang in ['fr']:
|
||||
entries = entries.exclude(lang='de')
|
||||
return entries[:6]
|
||||
return entries[:3]
|
||||
|
||||
def get_context(self, request):
|
||||
# Update template context
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
{{ entry.body|striptags|truncatewords_html:40 }}
|
||||
{% endif %}
|
||||
</p>
|
||||
<a href="{% pageurl entry %}" class="btn btn-default btn-xs"> ... </a>
|
||||
<a href="{% pageurl entry %}" class="btn btn-default btn-xs"> 🡆 </a>
|
||||
</div>
|
||||
<a href="{% pageurl entry %}" class="fill"></a>
|
||||
</div>
|
||||
|
@ -28,7 +28,7 @@
|
|||
{% empty %}
|
||||
<!-- No blogs today -->
|
||||
{% endfor %}
|
||||
<h4 class="partner-news"><a href="/aktuelles/">Partner news</a></h4>
|
||||
<!-- <h4 class="partner-news"><a href="/aktuelles/">Partner news</a></h4> -->
|
||||
{% for entry in newsentries %}
|
||||
<!-- News entry {{ entry.id }} -->
|
||||
<div class="col-md-4 col-sm-6 col-xs-12 news-entry">
|
||||
|
@ -45,7 +45,8 @@
|
|||
<em><span>{{ entry.author }}</span></em>
|
||||
</p>
|
||||
</div>
|
||||
<a href="{{ entry.link }}" target="_blank" class="fill"></a>
|
||||
<a href="/aktuelles/" target="_blank" class="fill"></a>
|
||||
<!-- <a href="{{ entry.link }}" target="_blank" class="fill"></a> -->
|
||||
</div>
|
||||
</div>
|
||||
{% empty %}
|
||||
|
|
|
@ -91,7 +91,7 @@
|
|||
}
|
||||
.panel-body {
|
||||
// height: 50%;
|
||||
background-color: #f0f0f0;
|
||||
background-color: #ffffff;
|
||||
border-radius: 4px;
|
||||
border-top: 3px solid $brand-primary;
|
||||
// border: 2px solid rgba(38, 67, 169, 0.8);
|
||||
|
|
Loading…
Reference in a new issue