Skip to content

Commit 318c8b8

Browse files
committed
Fixes #7721: Retain pagination preference when MAX_PAGE_SIZE is zero
1 parent 7085fe7 commit 318c8b8

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

docs/release-notes/version-3.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
* [#7647](https://github.com/netbox-community/netbox/issues/7647) - Require interface assignment when designating IP address as primary for device/VM during CSV import
2020
* [#7664](https://github.com/netbox-community/netbox/issues/7664) - Preserve initial form data when bulk edit validation fails
2121
* [#7717](https://github.com/netbox-community/netbox/issues/7717) - Restore missing tags column on IP range table
22+
* [#7721](https://github.com/netbox-community/netbox/issues/7721) - Retain pagination preference when `MAX_PAGE_SIZE` is zero
2223

2324
---
2425

netbox/utilities/paginator.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,22 @@ def get_paginate_count(request):
5757
5858
Return the lesser of the calculated value and MAX_PAGE_SIZE.
5959
"""
60+
def _max_allowed(page_size):
61+
if settings.MAX_PAGE_SIZE:
62+
return min(page_size, settings.MAX_PAGE_SIZE)
63+
return page_size
64+
6065
if 'per_page' in request.GET:
6166
try:
6267
per_page = int(request.GET.get('per_page'))
6368
if request.user.is_authenticated:
6469
request.user.config.set('pagination.per_page', per_page, commit=True)
65-
return min(per_page, settings.MAX_PAGE_SIZE)
70+
return _max_allowed(per_page)
6671
except ValueError:
6772
pass
6873

6974
if request.user.is_authenticated:
7075
per_page = request.user.config.get('pagination.per_page', settings.PAGINATE_COUNT)
71-
return min(per_page, settings.MAX_PAGE_SIZE)
76+
return _max_allowed(per_page)
7277

73-
return min(settings.PAGINATE_COUNT, settings.MAX_PAGE_SIZE)
78+
return _max_allowed(settings.PAGINATE_COUNT)

0 commit comments

Comments
 (0)