mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 01:41:22 -06:00
Fixes #2985: Fix pagination page length for rack elevations
This commit is contained in:
parent
f4b85751bb
commit
7e70bfaacc
@ -23,6 +23,7 @@ v2.5.8 (FUTURE)
|
|||||||
* [#2976](https://github.com/digitalocean/netbox/issues/2976) - Add delete button to tag view
|
* [#2976](https://github.com/digitalocean/netbox/issues/2976) - Add delete button to tag view
|
||||||
* [#2980](https://github.com/digitalocean/netbox/issues/2980) - Improve rendering time for API docs
|
* [#2980](https://github.com/digitalocean/netbox/issues/2980) - Improve rendering time for API docs
|
||||||
* [#2984](https://github.com/digitalocean/netbox/issues/2984) - Fix logging of unlabeled cable ID on cable deletion
|
* [#2984](https://github.com/digitalocean/netbox/issues/2984) - Fix logging of unlabeled cable ID on cable deletion
|
||||||
|
* [#2985](https://github.com/digitalocean/netbox/issues/2985) - Fix pagination page length for rack elevations
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.auth.mixins import PermissionRequiredMixin
|
from django.contrib.auth.mixins import PermissionRequiredMixin
|
||||||
from django.core.paginator import EmptyPage, PageNotAnInteger
|
from django.core.paginator import EmptyPage, PageNotAnInteger
|
||||||
@ -353,8 +354,9 @@ class RackElevationListView(View):
|
|||||||
total_count = racks.count()
|
total_count = racks.count()
|
||||||
|
|
||||||
# Pagination
|
# Pagination
|
||||||
paginator = EnhancedPaginator(racks, 25)
|
per_page = request.GET.get('per_page', settings.PAGINATE_COUNT)
|
||||||
page_number = request.GET.get('page', 1)
|
page_number = request.GET.get('page', 1)
|
||||||
|
paginator = EnhancedPaginator(racks, per_page)
|
||||||
try:
|
try:
|
||||||
page = paginator.page(page_number)
|
page = paginator.page(page_number)
|
||||||
except PageNotAnInteger:
|
except PageNotAnInteger:
|
||||||
|
@ -5,8 +5,13 @@ from django.core.paginator import Paginator, Page
|
|||||||
class EnhancedPaginator(Paginator):
|
class EnhancedPaginator(Paginator):
|
||||||
|
|
||||||
def __init__(self, object_list, per_page, **kwargs):
|
def __init__(self, object_list, per_page, **kwargs):
|
||||||
if not isinstance(per_page, int) or per_page < 1:
|
try:
|
||||||
per_page = getattr(settings, 'PAGINATE_COUNT', 50)
|
per_page = int(per_page)
|
||||||
|
if per_page < 1:
|
||||||
|
per_page = settings.PAGINATE_COUNT
|
||||||
|
except ValueError:
|
||||||
|
per_page = settings.PAGINATE_COUNT
|
||||||
|
|
||||||
super().__init__(object_list, per_page, **kwargs)
|
super().__init__(object_list, per_page, **kwargs)
|
||||||
|
|
||||||
def _get_page(self, *args, **kwargs):
|
def _get_page(self, *args, **kwargs):
|
||||||
|
Loading…
Reference in New Issue
Block a user