[bitbake-devel] [PATCH 04/12] toaster: layerdetails Fix pagination controls

Alex DAMIAN alexandru.damian at intel.com
Tue Feb 24 17:20:52 UTC 2015


From: Michael Wood <michael.g.wood at intel.com>

Bring the pagination controls into line with others in toaster by
limiting the number of page buttons to 5

[YOCTO #7195]

Signed-off-by: Michael Wood <michael.g.wood at intel.com>
---
 lib/toaster/toastergui/templates/layerdetails.html |  4 ++--
 lib/toaster/toastergui/views.py                    | 20 ++------------------
 2 files changed, 4 insertions(+), 20 deletions(-)

diff --git a/lib/toaster/toastergui/templates/layerdetails.html b/lib/toaster/toastergui/templates/layerdetails.html
index 49c62c6..1f48c65 100644
--- a/lib/toaster/toastergui/templates/layerdetails.html
+++ b/lib/toaster/toastergui/templates/layerdetails.html
@@ -287,7 +287,7 @@
                       {%else%}
                       <li class="disabled"><a href="#">&laquo;</a></li>
                       {%endif%}
-                      {% for i in targets.paginator.page_range %}
+                      {% for i in targets.page_range %}
                       <li {%if i == targets.number %} class="active" {%endif%}><a href="?tpage={{i}}#targets">{{i}}</a></li>
                       {% endfor %}
                       {%if targets.has_next%}
@@ -418,7 +418,7 @@
                       {%else%}
                       <li class="disabled"><a href="#">&laquo;</a></li>
                       {%endif%}
-                      {% for i in machines.paginator.page_range %}
+                      {% for i in machines.page_range %}
                       <li {%if i == machines.number %} class="active" {%endif%}><a href="?mpage={{i}}#machines">{{i}}</a></li>
                       {% endfor %}
                       {%if machines.has_next%}
diff --git a/lib/toaster/toastergui/views.py b/lib/toaster/toastergui/views.py
index 196e66e..0284b1a 100755
--- a/lib/toaster/toastergui/views.py
+++ b/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,
-- 
1.9.1




More information about the bitbake-devel mailing list