mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Remember user's per_page preference (POC for UserConfig)
This commit is contained in:
@ -37,3 +37,22 @@ class EnhancedPage(Page):
|
||||
page_list.insert(page_list.index(i), False)
|
||||
|
||||
return page_list
|
||||
|
||||
|
||||
def get_paginate_count(request):
|
||||
"""
|
||||
Determine the length of a page, using the following in order:
|
||||
|
||||
1. per_page URL query parameter
|
||||
2. Saved user preference
|
||||
3. PAGINATE_COUNT global setting.
|
||||
"""
|
||||
if 'per_page' in request.GET:
|
||||
try:
|
||||
per_page = int(request.GET.get('per_page'))
|
||||
request.user.config.set('paginate_count', per_page, commit=True)
|
||||
return per_page
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
return request.user.config.get('paginate_count', settings.PAGINATE_COUNT)
|
||||
|
Reference in New Issue
Block a user