Skip to content

Commit

Permalink
Revert "Raise ImproperlyConfigured error if MAX_PAGE_SIZE < PAGINATE_…
Browse files Browse the repository at this point in the history
…COUNT"

This reverts commit 5dd93c0.
  • Loading branch information
bctiemann committed Dec 12, 2024
1 parent b141f8c commit 14d6fd1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
4 changes: 3 additions & 1 deletion netbox/netbox/api/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ def paginate_queryset(self, queryset, request, view=None):

def get_limit(self, request):
if self.limit_query_param:
MAX_PAGE_SIZE = get_config().MAX_PAGE_SIZE
if MAX_PAGE_SIZE:
MAX_PAGE_SIZE = max(MAX_PAGE_SIZE, self.default_limit)
try:
limit = int(request.query_params[self.limit_query_param])
if limit < 0:
raise ValueError()
# Enforce maximum page size, if defined
MAX_PAGE_SIZE = get_config().MAX_PAGE_SIZE
if MAX_PAGE_SIZE:
return MAX_PAGE_SIZE if limit == 0 else min(limit, MAX_PAGE_SIZE)
return limit
Expand Down
6 changes: 0 additions & 6 deletions netbox/netbox/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,8 @@
LOGIN_REQUIRED = getattr(configuration, 'LOGIN_REQUIRED', True)
LOGIN_TIMEOUT = getattr(configuration, 'LOGIN_TIMEOUT', None)
LOGOUT_REDIRECT_URL = getattr(configuration, 'LOGOUT_REDIRECT_URL', 'home')
MAX_PAGE_SIZE = getattr(configuration, 'MAX_PAGE_SIZE', 1000)
MEDIA_ROOT = getattr(configuration, 'MEDIA_ROOT', os.path.join(BASE_DIR, 'media')).rstrip('/')
METRICS_ENABLED = getattr(configuration, 'METRICS_ENABLED', False)
PAGINATE_COUNT = getattr(configuration, 'PAGINATE_COUNT', 50)
PLUGINS = getattr(configuration, 'PLUGINS', [])
PLUGINS_CONFIG = getattr(configuration, 'PLUGINS_CONFIG', {})
QUEUE_MAPPINGS = getattr(configuration, 'QUEUE_MAPPINGS', {})
Expand Down Expand Up @@ -687,10 +685,6 @@ def _setting(name, default=None):
'VIEW_NAME_FUNCTION': 'utilities.api.get_view_name',
}

if MAX_PAGE_SIZE < PAGINATE_COUNT:
raise ImproperlyConfigured(f'MAX_PAGE_SIZE ({MAX_PAGE_SIZE}) cannot be less than PAGINATE_COUNT ({PAGINATE_COUNT}).')


#
# DRF Spectacular
#
Expand Down

0 comments on commit 14d6fd1

Please sign in to comment.