diff --git a/arkindex/dataimport/tests/test_process_elements.py b/arkindex/dataimport/tests/test_process_elements.py index fcebe116408debb879abd20fdebe2553387a78ca..80e3cb7240292b971904214197c9f6d7b466821f 100644 --- a/arkindex/dataimport/tests/test_process_elements.py +++ b/arkindex/dataimport/tests/test_process_elements.py @@ -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) diff --git a/arkindex/project/mixins.py b/arkindex/project/mixins.py index 8ce92cc564dd2246421bcf9eade971c00f386499..94c5d0b982285a4338402bba2ce1aa0179ba5815 100644 --- a/arkindex/project/mixins.py +++ b/arkindex/project/mixins.py @@ -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 diff --git a/arkindex/project/pagination.py b/arkindex/project/pagination.py index d88073ccea63ae8fd8efbe19f8ea16115a6b1c3e..14929b2baeb0cf4d265e46e0b7d9325cded3e3cd 100644 --- a/arkindex/project/pagination.py +++ b/arkindex/project/pagination.py @@ -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', }