Procházet zdrojové kódy

Fixes #5206: Apply user pagination preferences to all paginated object lists

Jeremy Stretch před 5 roky
rodič
revize
ae0a481c64

+ 2 - 1
docs/release-notes/version-2.9.md

@@ -9,7 +9,8 @@
 * [#5175](https://github.com/netbox-community/netbox/issues/5175) - Fix toggling of rack elevation order
 * [#5175](https://github.com/netbox-community/netbox/issues/5175) - Fix toggling of rack elevation order
 * [#5184](https://github.com/netbox-community/netbox/issues/5184) - Fix missing Power Utilization
 * [#5184](https://github.com/netbox-community/netbox/issues/5184) - Fix missing Power Utilization
 * [#5199](https://github.com/netbox-community/netbox/issues/5199) - Change default LDAP logging to INFO
 * [#5199](https://github.com/netbox-community/netbox/issues/5199) - Change default LDAP logging to INFO
-* [#5201](https://github.com/netbox-community/netbox/issues/5201) - Fix missing querystring when bulk editing/deleting VLAN Group Vlans when selecting "select all x items matching query"
+* [#5201](https://github.com/netbox-community/netbox/issues/5201) - Fix missing querystring when bulk editing/deleting VLAN Group VLANs when selecting "select all x items matching query"
+* [#5206](https://github.com/netbox-community/netbox/issues/5206) - Apply user pagination preferences to all paginated object lists
 
 
 ---
 ---
 
 

+ 3 - 4
netbox/circuits/views.py

@@ -1,13 +1,12 @@
-from django.conf import settings
 from django.contrib import messages
 from django.contrib import messages
 from django.db import transaction
 from django.db import transaction
-from django.db.models import Count, Prefetch
+from django.db.models import Count
 from django.shortcuts import get_object_or_404, redirect, render
 from django.shortcuts import get_object_or_404, redirect, render
 from django_tables2 import RequestConfig
 from django_tables2 import RequestConfig
 
 
 from extras.models import Graph
 from extras.models import Graph
 from utilities.forms import ConfirmationForm
 from utilities.forms import ConfirmationForm
-from utilities.paginator import EnhancedPaginator
+from utilities.paginator import EnhancedPaginator, get_paginate_count
 from utilities.views import (
 from utilities.views import (
     BulkDeleteView, BulkEditView, BulkImportView, ObjectView, ObjectDeleteView, ObjectEditView, ObjectListView,
     BulkDeleteView, BulkEditView, BulkImportView, ObjectView, ObjectDeleteView, ObjectEditView, ObjectListView,
 )
 )
@@ -45,7 +44,7 @@ class ProviderView(ObjectView):
 
 
         paginate = {
         paginate = {
             'paginator_class': EnhancedPaginator,
             'paginator_class': EnhancedPaginator,
-            'per_page': request.GET.get('per_page', settings.PAGINATE_COUNT)
+            'per_page': get_paginate_count(request)
         }
         }
         RequestConfig(request, paginate).configure(circuits_table)
         RequestConfig(request, paginate).configure(circuits_table)
 
 

+ 2 - 3
netbox/dcim/views.py

@@ -1,6 +1,5 @@
 from collections import OrderedDict
 from collections import OrderedDict
 
 
-from django.conf import settings
 from django.contrib import messages
 from django.contrib import messages
 from django.contrib.contenttypes.models import ContentType
 from django.contrib.contenttypes.models import ContentType
 from django.core.paginator import EmptyPage, PageNotAnInteger
 from django.core.paginator import EmptyPage, PageNotAnInteger
@@ -20,7 +19,7 @@ from ipam.models import IPAddress, Prefix, Service, VLAN
 from ipam.tables import InterfaceIPAddressTable, InterfaceVLANTable
 from ipam.tables import InterfaceIPAddressTable, InterfaceVLANTable
 from secrets.models import Secret
 from secrets.models import Secret
 from utilities.forms import ConfirmationForm
 from utilities.forms import ConfirmationForm
-from utilities.paginator import EnhancedPaginator
+from utilities.paginator import EnhancedPaginator, get_paginate_count
 from utilities.permissions import get_permission_for_model
 from utilities.permissions import get_permission_for_model
 from utilities.utils import csv_format, get_subquery
 from utilities.utils import csv_format, get_subquery
 from utilities.views import (
 from utilities.views import (
@@ -320,7 +319,7 @@ class RackElevationListView(ObjectListView):
             racks = racks.reverse()
             racks = racks.reverse()
 
 
         # Pagination
         # Pagination
-        per_page = request.GET.get('per_page', settings.PAGINATE_COUNT)
+        per_page = get_paginate_count(request)
         page_number = request.GET.get('page', 1)
         page_number = request.GET.get('page', 1)
         paginator = EnhancedPaginator(racks, per_page)
         paginator = EnhancedPaginator(racks, per_page)
         try:
         try:

+ 2 - 3
netbox/extras/views.py

@@ -1,5 +1,4 @@
 from django import template
 from django import template
-from django.conf import settings
 from django.contrib import messages
 from django.contrib import messages
 from django.contrib.contenttypes.models import ContentType
 from django.contrib.contenttypes.models import ContentType
 from django.db.models import Count, Prefetch, Q
 from django.db.models import Count, Prefetch, Q
@@ -13,7 +12,7 @@ from rq import Worker
 from dcim.models import DeviceRole, Platform, Region, Site
 from dcim.models import DeviceRole, Platform, Region, Site
 from tenancy.models import Tenant, TenantGroup
 from tenancy.models import Tenant, TenantGroup
 from utilities.forms import ConfirmationForm
 from utilities.forms import ConfirmationForm
-from utilities.paginator import EnhancedPaginator
+from utilities.paginator import EnhancedPaginator, get_paginate_count
 from utilities.utils import copy_safe_request, shallow_compare_dict
 from utilities.utils import copy_safe_request, shallow_compare_dict
 from utilities.views import (
 from utilities.views import (
     BulkDeleteView, BulkEditView, BulkImportView, ObjectView, ObjectDeleteView, ObjectEditView, ObjectListView,
     BulkDeleteView, BulkEditView, BulkImportView, ObjectView, ObjectDeleteView, ObjectEditView, ObjectListView,
@@ -258,7 +257,7 @@ class ObjectChangeLogView(View):
         # Apply the request context
         # Apply the request context
         paginate = {
         paginate = {
             'paginator_class': EnhancedPaginator,
             'paginator_class': EnhancedPaginator,
-            'per_page': request.GET.get('per_page', settings.PAGINATE_COUNT)
+            'per_page': get_paginate_count(request)
         }
         }
         RequestConfig(request, paginate).configure(objectchanges_table)
         RequestConfig(request, paginate).configure(objectchanges_table)
 
 

+ 8 - 8
netbox/ipam/views.py

@@ -6,7 +6,7 @@ from django.shortcuts import get_object_or_404, redirect, render
 from django_tables2 import RequestConfig
 from django_tables2 import RequestConfig
 
 
 from dcim.models import Device, Interface
 from dcim.models import Device, Interface
-from utilities.paginator import EnhancedPaginator
+from utilities.paginator import EnhancedPaginator, get_paginate_count
 from utilities.utils import get_subquery
 from utilities.utils import get_subquery
 from utilities.views import (
 from utilities.views import (
     BulkCreateView, BulkDeleteView, BulkEditView, BulkImportView, ObjectView, ObjectDeleteView, ObjectEditView,
     BulkCreateView, BulkDeleteView, BulkEditView, BulkImportView, ObjectView, ObjectDeleteView, ObjectEditView,
@@ -233,7 +233,7 @@ class AggregateView(ObjectView):
 
 
         paginate = {
         paginate = {
             'paginator_class': EnhancedPaginator,
             'paginator_class': EnhancedPaginator,
-            'per_page': request.GET.get('per_page', settings.PAGINATE_COUNT)
+            'per_page': get_paginate_count(request)
         }
         }
         RequestConfig(request, paginate).configure(prefix_table)
         RequestConfig(request, paginate).configure(prefix_table)
 
 
@@ -391,7 +391,7 @@ class PrefixPrefixesView(ObjectView):
 
 
         paginate = {
         paginate = {
             'paginator_class': EnhancedPaginator,
             'paginator_class': EnhancedPaginator,
-            'per_page': request.GET.get('per_page', settings.PAGINATE_COUNT)
+            'per_page': get_paginate_count(request)
         }
         }
         RequestConfig(request, paginate).configure(prefix_table)
         RequestConfig(request, paginate).configure(prefix_table)
 
 
@@ -435,7 +435,7 @@ class PrefixIPAddressesView(ObjectView):
 
 
         paginate = {
         paginate = {
             'paginator_class': EnhancedPaginator,
             'paginator_class': EnhancedPaginator,
-            'per_page': request.GET.get('per_page', settings.PAGINATE_COUNT)
+            'per_page': get_paginate_count(request)
         }
         }
         RequestConfig(request, paginate).configure(ip_table)
         RequestConfig(request, paginate).configure(ip_table)
 
 
@@ -539,7 +539,7 @@ class IPAddressView(ObjectView):
 
 
         paginate = {
         paginate = {
             'paginator_class': EnhancedPaginator,
             'paginator_class': EnhancedPaginator,
-            'per_page': request.GET.get('per_page', settings.PAGINATE_COUNT)
+            'per_page': get_paginate_count(request)
         }
         }
         RequestConfig(request, paginate).configure(related_ips_table)
         RequestConfig(request, paginate).configure(related_ips_table)
 
 
@@ -699,7 +699,7 @@ class VLANGroupVLANsView(ObjectView):
 
 
         paginate = {
         paginate = {
             'paginator_class': EnhancedPaginator,
             'paginator_class': EnhancedPaginator,
-            'per_page': request.GET.get('per_page', settings.PAGINATE_COUNT)
+            'per_page': get_paginate_count(request),
         }
         }
         RequestConfig(request, paginate).configure(vlan_table)
         RequestConfig(request, paginate).configure(vlan_table)
 
 
@@ -760,7 +760,7 @@ class VLANInterfacesView(ObjectView):
 
 
         paginate = {
         paginate = {
             'paginator_class': EnhancedPaginator,
             'paginator_class': EnhancedPaginator,
-            'per_page': request.GET.get('per_page', settings.PAGINATE_COUNT)
+            'per_page': get_paginate_count(request)
         }
         }
         RequestConfig(request, paginate).configure(members_table)
         RequestConfig(request, paginate).configure(members_table)
 
 
@@ -781,7 +781,7 @@ class VLANVMInterfacesView(ObjectView):
 
 
         paginate = {
         paginate = {
             'paginator_class': EnhancedPaginator,
             'paginator_class': EnhancedPaginator,
-            'per_page': request.GET.get('per_page', settings.PAGINATE_COUNT)
+            'per_page': get_paginate_count(request)
         }
         }
         RequestConfig(request, paginate).configure(members_table)
         RequestConfig(request, paginate).configure(members_table)