mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 01:41:22 -06:00
Fixes #7721: Retain pagination preference when MAX_PAGE_SIZE is zero
This commit is contained in:
parent
7085fe77da
commit
318c8b85e9
@ -19,6 +19,7 @@
|
||||
* [#7647](https://github.com/netbox-community/netbox/issues/7647) - Require interface assignment when designating IP address as primary for device/VM during CSV import
|
||||
* [#7664](https://github.com/netbox-community/netbox/issues/7664) - Preserve initial form data when bulk edit validation fails
|
||||
* [#7717](https://github.com/netbox-community/netbox/issues/7717) - Restore missing tags column on IP range table
|
||||
* [#7721](https://github.com/netbox-community/netbox/issues/7721) - Retain pagination preference when `MAX_PAGE_SIZE` is zero
|
||||
|
||||
---
|
||||
|
||||
|
@ -57,17 +57,22 @@ def get_paginate_count(request):
|
||||
|
||||
Return the lesser of the calculated value and MAX_PAGE_SIZE.
|
||||
"""
|
||||
def _max_allowed(page_size):
|
||||
if settings.MAX_PAGE_SIZE:
|
||||
return min(page_size, settings.MAX_PAGE_SIZE)
|
||||
return page_size
|
||||
|
||||
if 'per_page' in request.GET:
|
||||
try:
|
||||
per_page = int(request.GET.get('per_page'))
|
||||
if request.user.is_authenticated:
|
||||
request.user.config.set('pagination.per_page', per_page, commit=True)
|
||||
return min(per_page, settings.MAX_PAGE_SIZE)
|
||||
return _max_allowed(per_page)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
if request.user.is_authenticated:
|
||||
per_page = request.user.config.get('pagination.per_page', settings.PAGINATE_COUNT)
|
||||
return min(per_page, settings.MAX_PAGE_SIZE)
|
||||
return _max_allowed(per_page)
|
||||
|
||||
return min(settings.PAGINATE_COUNT, settings.MAX_PAGE_SIZE)
|
||||
return _max_allowed(settings.PAGINATE_COUNT)
|
||||
|
Loading…
Reference in New Issue
Block a user