Paginate past bulletin items
This commit is contained in:
parent
3193d06891
commit
97794b521f
@ -47,7 +47,7 @@
|
|||||||
{% block maincontent %}
|
{% block maincontent %}
|
||||||
<h1>Your bulletin items</h1>
|
<h1>Your bulletin items</h1>
|
||||||
|
|
||||||
{% if not items_past and not items_upcoming and not items_future %}
|
{% if not items_past_page and not items_upcoming and not items_future %}
|
||||||
<p>You have no bulletin items to view. To create a bulletin item, click <a href="{{ url('bulletin_new') }}">Create new bulletin item</a>.</p>
|
<p>You have no bulletin items to view. To create a bulletin item, click <a href="{{ url('bulletin_new') }}">Create new bulletin item</a>.</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
@ -63,10 +63,22 @@
|
|||||||
{{ listitems(items_future) }}
|
{{ listitems(items_future) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if items_past %}
|
{% if items_past_page %}
|
||||||
<h2>Past bulletin items</h2>
|
<h2>Past bulletin items</h2>
|
||||||
|
|
||||||
{{ listitems(items_past) }}
|
{{ listitems(items_past_page.object_list) }}
|
||||||
|
|
||||||
|
<div style="text-align: center;">
|
||||||
|
<div class="ui pagination menu">
|
||||||
|
{% if items_past_page.has_previous() %}
|
||||||
|
<a class="item" href="?page={{ items_past_page.previous_page_number() }}">‹ Prev</a>
|
||||||
|
{% endif %}
|
||||||
|
<a class="active item">Page {{ items_past_page.number }} of {{ items_past_page.paginator.num_pages }}</a>
|
||||||
|
{% if items_past_page.has_next() %}
|
||||||
|
<a class="item" href="?page={{ items_past_page.next_page_number() }}">Next ›</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.core.paginator import Paginator
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.shortcuts import render, redirect
|
from django.shortcuts import render, redirect
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
@ -52,8 +53,10 @@ def bulletin_list(request):
|
|||||||
else:
|
else:
|
||||||
items_past.append(item)
|
items_past.append(item)
|
||||||
|
|
||||||
|
items_past_p = Paginator(items_past, 10)
|
||||||
|
|
||||||
return render(request, 'sspromotions/bulletin_list.html', {
|
return render(request, 'sspromotions/bulletin_list.html', {
|
||||||
'items_past': items_past,
|
'items_past_page': items_past_p.page(int(request.GET.get('page', 1))) if items_past_p.count > 0 else None,
|
||||||
'items_upcoming': items_upcoming,
|
'items_upcoming': items_upcoming,
|
||||||
'items_future': items_future
|
'items_future': items_future
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user