Parcourir la source

Simplified paginator when dealing with <=5 pages

Jeremy Stretch il y a 8 ans
Parent
commit
5716207ba6
1 fichiers modifiés avec 4 ajouts et 0 suppressions
  1. 4 0
      netbox/utilities/paginator.py

+ 4 - 0
netbox/utilities/paginator.py

@@ -16,6 +16,10 @@ class EnhancedPage(Page):
 
     def smart_pages(self):
 
+        # When dealing with five or fewer pages, simply return the whole list.
+        if self.paginator.num_pages <= 5:
+            return self.paginator.page_range
+
         # Show first page, last page, next/previous two pages, and current page
         n = self.number
         pages_wanted = [1, n - 2, n - 1, n, n + 1, n + 2, self.paginator.num_pages]