mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-03 04:54:45 +00:00
Remove assert from WagtailPagination.paginate_queryset method
This commit is contained in:
parent
f7b0b6917c
commit
1ba4d84fb7
1 changed files with 10 additions and 8 deletions
|
|
@ -13,21 +13,23 @@ class WagtailPagination(BasePagination):
|
|||
|
||||
try:
|
||||
offset = int(request.GET.get('offset', 0))
|
||||
assert offset >= 0
|
||||
except (ValueError, AssertionError):
|
||||
if offset < 0:
|
||||
raise ValueError()
|
||||
except ValueError:
|
||||
raise BadRequestError("offset must be a positive integer")
|
||||
|
||||
try:
|
||||
limit_default = 20 if not limit_max else min(20, limit_max)
|
||||
limit = int(request.GET.get('limit', limit_default))
|
||||
|
||||
if limit_max and limit > limit_max:
|
||||
raise BadRequestError("limit cannot be higher than %d" % limit_max)
|
||||
|
||||
assert limit >= 0
|
||||
except (ValueError, AssertionError):
|
||||
if limit < 0:
|
||||
raise ValueError()
|
||||
except ValueError:
|
||||
raise BadRequestError("limit must be a positive integer")
|
||||
|
||||
if limit_max and limit > limit_max:
|
||||
raise BadRequestError(
|
||||
"limit cannot be higher than %d" % limit_max)
|
||||
|
||||
start = offset
|
||||
stop = offset + limit
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue