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
0bb6bef3
Commit
0bb6bef3
authored
4 years ago
by
Valentin Rigal
Browse files
Options
Downloads
Patches
Plain Diff
Remove with count validation
parent
b67176a0
No related branches found
No related tags found
1 merge request
!1043
Custom cursor pagination for process elements
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
arkindex/dataimport/tests/test_process_elements.py
+1
-7
1 addition, 7 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
4 additions
and
13 deletions
arkindex/dataimport/tests/test_process_elements.py
+
1
−
7
View file @
0bb6bef3
...
...
@@ -678,7 +678,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
):
...
...
@@ -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
)
This diff is collapsed.
Click to expand it.
arkindex/project/mixins.py
+
2
−
5
View file @
0bb6bef3
...
...
@@ -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 @
0bb6bef3
...
...
@@ -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.
Valentin Rigal
@vrigal
mentioned in commit
c494d507
·
4 years ago
mentioned in commit
c494d507
Edited
4 years ago
by
Ghost User
mentioned in commit c494d507849c253e107fabcd8d9c787e84bdf096
Toggle commit list
Valentin Rigal
@vrigal
mentioned in commit
ec0695e9
·
4 years ago
mentioned in commit
ec0695e9
Edited
4 years ago
by
Ghost User
mentioned in commit ec0695e9881ade78eeb5e8aae0ee119cb4286f1d
Toggle commit list
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