8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-26 08:53:46 +00:00

Paginator pour room

This commit is contained in:
Gabriel Detraz 2017-09-02 15:40:44 +02:00 committed by root
parent 8305fd94ee
commit 047e495f67
3 changed files with 17 additions and 0 deletions

View file

@ -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>

View file

@ -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 />

View file

@ -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