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

Paginator pour room

parent 948091f4
......@@ -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 room_list.paginator %}
{% include "pagination.html" with list=room_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>Chambres</h2>
{% if is_infra %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:new-room' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter une chambre</a>
<hr>
{% endif %}
{% include "topologie/aff_chambres.html" with room_list=room_list %}
<br />
......
......@@ -105,6 +105,18 @@ def index_port(request, switch_id):
@permission_required('cableur')
def index_room(request):
room_list = Room.objects.order_by('name')
options, created = GeneralOption.objects.get_or_create()
pagination_number = options.pagination_number
paginator = Paginator(room_list, pagination_number)
page = request.GET.get('page')
try:
room_list = paginator.page(page)
except PageNotAnInteger:
# If page is not an integer, deliver first page.
room_list = paginator.page(1)
except EmptyPage:
# If page is out of range (e.g. 9999), deliver last page of results.
room_list = paginator.page(paginator.num_pages)
return render(request, 'topologie/index_room.html', {'room_list': room_list})
@login_required
......
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