Commit 22631c73 by Tom Christie

Resolve assertion error with LimitOffsetPagination and erronous parameters. Closes #2920.

parent 762a30db
......@@ -419,6 +419,8 @@ class LimitOffsetPagination(BasePagination):
_divide_with_ceil(self.count - self.offset, self.limit) +
_divide_with_ceil(self.offset, self.limit)
)
if current > final:
current = final
def page_number_to_url(page_number):
if page_number == 1:
......
......@@ -435,6 +435,12 @@ class TestLimitOffset:
]
}
def test_erronous_offset(self):
request = Request(factory.get('/', {'limit': 5, 'offset': 1000}))
queryset = self.paginate_queryset(request)
self.get_paginated_content(queryset)
self.get_html_context()
def test_invalid_offset(self):
"""
An invalid offset query param should be treated as 0.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment