Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
4df6915a
Commit
4df6915a
authored
4 years ago
by
Valentin Rigal
Browse files
Options
Downloads
Patches
Plain Diff
Remove with count validation
parent
b856f13b
No related branches found
No related tags found
1 merge request
!1048
Remove with count validation
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
arkindex/dataimport/tests/test_process_elements.py
+3
-2
3 additions, 2 deletions
arkindex/dataimport/tests/test_process_elements.py
arkindex/project/mixins.py
+2
-5
2 additions, 5 deletions
arkindex/project/mixins.py
arkindex/project/pagination.py
+1
-1
1 addition, 1 deletion
arkindex/project/pagination.py
with
6 additions
and
8 deletions
arkindex/dataimport/tests/test_process_elements.py
+
3
−
2
View file @
4df6915a
...
...
@@ -679,7 +679,7 @@ class TestProcessElements(FixtureAPITestCase):
def
test_elements_count
(
self
):
"""
Elements count can be retrieved w
hen no cursor is set
Elements count can be retrieved w
ith 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
)
...
...
This diff is collapsed.
Click to expand it.
arkindex/project/mixins.py
+
2
−
5
View file @
4df6915a
...
...
@@ -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
This diff is collapsed.
Click to expand it.
arkindex/project/pagination.py
+
1
−
1
View file @
4df6915a
...
...
@@ -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
'
,
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment