1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Add PAGINATE_COUNT, MAX_PAGE_SIZE

This commit is contained in:
jeremystretch
2021-10-26 11:39:39 -04:00
parent 94804fecd8
commit 64d8512fc3
9 changed files with 62 additions and 58 deletions

View File

@@ -9,6 +9,7 @@ from rest_framework.decorators import action
from rest_framework.response import Response
from ipam.models import *
from netbox.config import Config
from utilities.constants import ADVISORY_LOCK_KEYS
from . import serializers
@@ -160,12 +161,15 @@ class AvailableIPsMixin:
# Determine the maximum number of IPs to return
else:
config = Config()
PAGINATE_COUNT = config.PAGINATE_COUNT
MAX_PAGE_SIZE = config.MAX_PAGE_SIZE
try:
limit = int(request.query_params.get('limit', settings.PAGINATE_COUNT))
limit = int(request.query_params.get('limit', PAGINATE_COUNT))
except ValueError:
limit = settings.PAGINATE_COUNT
if settings.MAX_PAGE_SIZE:
limit = min(limit, settings.MAX_PAGE_SIZE)
limit = PAGINATE_COUNT
if MAX_PAGE_SIZE:
limit = min(limit, MAX_PAGE_SIZE)
# Calculate available IPs within the parent
ip_list = []