From 4742ae94a91028f7128b862fdb6ec80123749859 Mon Sep 17 00:00:00 2001 From: Michael Wood Date: Tue, 24 Feb 2015 17:20:52 +0000 Subject: [PATCH] bitbake: toaster: layerdetails Fix pagination controls Bring the pagination controls into line with others in toaster by limiting the number of page buttons to 5 [YOCTO #7195] (Bitbake rev: 0b35eed7ca758476f20d6875291ee31fad35b7d3) Signed-off-by: Michael Wood Signed-off-by: Richard Purdie --- .../toastergui/templates/layerdetails.html | 4 ++-- bitbake/lib/toaster/toastergui/views.py | 20 ++----------------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/bitbake/lib/toaster/toastergui/templates/layerdetails.html b/bitbake/lib/toaster/toastergui/templates/layerdetails.html index 49c62c6bc0..1f48c653a9 100644 --- a/bitbake/lib/toaster/toastergui/templates/layerdetails.html +++ b/bitbake/lib/toaster/toastergui/templates/layerdetails.html @@ -287,7 +287,7 @@ {%else%}
  • «
  • {%endif%} - {% for i in targets.paginator.page_range %} + {% for i in targets.page_range %}
  • {{i}}
  • {% endfor %} {%if targets.has_next%} @@ -418,7 +418,7 @@ {%else%}
  • «
  • {%endif%} - {% for i in machines.paginator.page_range %} + {% for i in machines.page_range %}
  • {{i}}
  • {% endfor %} {%if machines.has_next%} diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index 196e66ea1b..0284b1abcd 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py @@ -2630,15 +2630,7 @@ if toastermain.settings.MANAGED: Q(name__icontains=request.GET['targets_search']) | Q(summary__icontains=request.GET['targets_search'])) - targets = Paginator(targets_query.order_by("name"), limit) - - if request.GET.has_key("tpage"): - try: - targets = targets.page(request.GET['tpage']) - except EmptyPage: - targets = targets.page(targets.num_pages) - else: - targets = targets.page(1) + targets = _build_page_range(Paginator(targets_query.order_by("name"), limit), request.GET.get('tpage', 1)) machines_query = Machine.objects.filter(layer_version=layer_version) @@ -2648,15 +2640,7 @@ if toastermain.settings.MANAGED: Q(name__icontains=request.GET['machines_search']) | Q(description__icontains=request.GET['machines_search'])) - machines = Paginator(machines_query.order_by("name"), limit) - - if request.GET.has_key("mpage"): - try: - machines = machines.page(request.GET['mpage']) - except EmptyPage: - machines = machines.page(machines.num_pages) - else: - machines = machines.page(1) + machines = _build_page_range(Paginator(machines_query.order_by("name"), limit), request.GET.get('mpage', 1)) context = { 'layerversion': layer_version,