diff --git a/topologie/templates/topologie/aff_switch.html b/topologie/templates/topologie/aff_switch.html index eb326421..6542ce13 100644 --- a/topologie/templates/topologie/aff_switch.html +++ b/topologie/templates/topologie/aff_switch.html @@ -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 %} + diff --git a/topologie/templates/topologie/index.html b/topologie/templates/topologie/index.html index 72b522d0..6b17b6de 100644 --- a/topologie/templates/topologie/index.html +++ b/topologie/templates/topologie/index.html @@ -31,6 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,

Switchs

{% if is_infra %} Ajouter un switch +
{% endif %} {% include "topologie/aff_switch.html" with switch_list=switch_list %}
diff --git a/topologie/views.py b/topologie/views.py index 5cd413f7..d72be310 100644 --- a/topologie/views.py +++ b/topologie/views.py @@ -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 })