Skip to content
Snippets Groups Projects
Commit 0bb6bef3 authored by Valentin Rigal's avatar Valentin Rigal
Browse files

Remove with count validation

parent b67176a0
No related branches found
No related tags found
1 merge request!1043Custom cursor pagination for process elements
......@@ -678,7 +678,7 @@ class TestProcessElements(FixtureAPITestCase):
def test_elements_count(self):
"""
Elements count can be retrieved when no cursor is set
Elements count can be retrieved with with_count parameter
"""
self.client.force_login(self.superuser)
with self.assertNumQueries(7):
......@@ -693,9 +693,3 @@ class TestProcessElements(FixtureAPITestCase):
self.assertEqual(len(data['results']), 6)
next_url = data.get('next')
self.assertIn('cursor', next_url)
second_page = self.client.get(next_url)
data = second_page.json()
self.assertIsNone(data['count'])
self.assertIsNone(data['next'])
self.assertEqual(len(data['results']), 6)
......@@ -164,7 +164,7 @@ class CachedViewMixin(object):
class CustomPaginationViewMixin(object):
"""
A custom cursor pagination mixin
Elements count can be retrieved with the `with_count` parameter if there is no cursor
Elements count can be retrieved with the `with_count` parameter
"""
pagination_class = CustomCursorPagination
......@@ -172,9 +172,6 @@ class CustomPaginationViewMixin(object):
def paginator(self):
if not hasattr(self, '_paginator'):
params = self.request.query_params
with_count = (
not params.get('cursor')
and params.get('with_count') not in (None, '', 'false', '0')
)
with_count = params.get('with_count') not in (None, '', 'false', '0')
self._paginator = self.pagination_class(with_count=with_count)
return self._paginator
......@@ -62,7 +62,7 @@ class CustomCursorPagination(pagination.CursorPagination):
'name': 'with_count',
'required': False,
'in': 'query',
'description': 'Count the total number of elements. Incompatible with `cursor` parameter.',
'description': 'Count the total number of elements.',
'schema': {
'type': 'boolean',
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment