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

Remove with count validation

parent b856f13b
No related branches found
No related tags found
1 merge request!1048Remove with count validation
......@@ -679,7 +679,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):
......@@ -697,7 +697,8 @@ class TestProcessElements(FixtureAPITestCase):
second_page = self.client.get(next_url)
data = second_page.json()
self.assertIsNone(data['count'])
# Count should be present in the next URL
self.assertEqual(data['count'], 12)
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