Commit a2e03538 authored by Gabriel Detraz's avatar Gabriel Detraz Committed by root

Gentil paginateur

parent 315560ba
......@@ -22,6 +22,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
{% endcomment %}
{% if switch_list.paginator %}
{% include "pagination.html" with list=switch_list %}
{% endif %}
<table class="table table-striped">
<thead>
<tr>
......
......@@ -31,6 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<h2>Switchs</h2>
{% if is_infra %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:new-switch' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un switch</a>
<hr>
{% endif %}
{% include "topologie/aff_switch.html" with switch_list=switch_list %}
<br />
......
......@@ -89,6 +89,18 @@ def index(request):
request.GET.get('order'),
SortTable.TOPOLOGIE_INDEX
)
options, _created = GeneralOption.objects.get_or_create()
pagination_number = options.pagination_number
paginator = Paginator(switch_list, pagination_number)
page = request.GET.get('page')
try:
switch_list = paginator.page(page)
except PageNotAnInteger:
# If page is not an integer, deliver first page.
switch_list = paginator.page(1)
except EmptyPage:
# If page is out of range (e.g. 9999), deliver last page of results.
switch_list = paginator.page(paginator.num_pages)
return render(request, 'topologie/index.html', {
'switch_list': switch_list
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment