Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
14a32ae3
Commit
14a32ae3
authored
Jul 14, 2015
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add get_page_size hook to CursorPagination. Closes #3068.
parent
1d012aeb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
38 deletions
+0
-38
rest_framework/pagination.py
+0
-18
tests/test_pagination.py
+0
-20
No files found.
rest_framework/pagination.py
View file @
14a32ae3
...
...
@@ -454,14 +454,6 @@ class CursorPagination(BasePagination):
# Defaults to `None`, meaning pagination is disabled.
page_size
=
api_settings
.
PAGE_SIZE
# Client can control the page size using this query parameter.
# Default is 'None'. Set to eg 'page_size' to enable usage.
page_size_query_param
=
None
# Set to an integer to limit the maximum page size the client may request.
# Only relevant if 'page_size_query_param' has also been set.
max_page_size
=
None
invalid_cursor_message
=
_
(
'Invalid cursor'
)
ordering
=
'-created'
template
=
'rest_framework/pagination/previous_and_next.html'
...
...
@@ -544,16 +536,6 @@ class CursorPagination(BasePagination):
return
self
.
page
def
get_page_size
(
self
,
request
):
if
self
.
page_size_query_param
:
try
:
return
_positive_int
(
request
.
query_params
[
self
.
page_size_query_param
],
strict
=
True
,
cutoff
=
self
.
max_page_size
)
except
(
KeyError
,
ValueError
):
pass
return
self
.
page_size
def
get_next_link
(
self
):
...
...
tests/test_pagination.py
View file @
14a32ae3
...
...
@@ -513,8 +513,6 @@ class TestCursorPagination:
class
ExamplePagination
(
pagination
.
CursorPagination
):
page_size
=
5
page_size_query_param
=
'page_size'
max_page_size
=
20
ordering
=
'created'
self
.
pagination
=
ExamplePagination
()
...
...
@@ -650,24 +648,6 @@ class TestCursorPagination:
assert
isinstance
(
self
.
pagination
.
to_html
(),
type
(
''
))
def
test_page_size
(
self
):
(
previous
,
current
,
next
,
previous_url
,
next_url
)
=
\
self
.
get_pages
(
'/?page_size=10'
)
assert
previous
is
None
assert
current
==
[
1
,
1
,
1
,
1
,
1
,
1
,
2
,
3
,
4
,
4
]
assert
next
==
[
4
,
4
,
5
,
6
,
7
,
7
,
7
,
7
,
7
,
7
]
assert
'page_size=10'
in
next_url
(
previous
,
current
,
next
,
previous_url
,
next_url
)
=
\
self
.
get_pages
(
next_url
.
replace
(
'page_size=10'
,
'page_size=4'
))
assert
previous
==
[
2
,
3
,
4
,
4
]
assert
current
==
[
4
,
4
,
5
,
6
]
assert
next
==
[
7
,
7
,
7
,
7
]
assert
'page_size=4'
in
previous_url
assert
'page_size=4'
in
next_url
def
test_get_displayed_page_numbers
():
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment