mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 20:40:14 +03:00
Merge 443b2aafd9
into 6831472a62
This commit is contained in:
commit
3dea588534
|
@ -568,7 +568,7 @@ class CursorPagination(BasePagination):
|
|||
def get_page_size(self, request):
|
||||
return self.page_size
|
||||
|
||||
def get_next_link(self):
|
||||
def get_next_cursor(self):
|
||||
if not self.has_next:
|
||||
return None
|
||||
|
||||
|
@ -613,10 +613,15 @@ class CursorPagination(BasePagination):
|
|||
offset = self.cursor.offset + self.page_size
|
||||
position = self.previous_position
|
||||
|
||||
cursor = Cursor(offset=offset, reverse=False, position=position)
|
||||
return self.encode_cursor(cursor)
|
||||
return Cursor(offset=offset, reverse=False, position=position)
|
||||
|
||||
def get_previous_link(self):
|
||||
def get_next_link(self):
|
||||
cursor = self.get_next_cursor()
|
||||
if not cursor:
|
||||
return None
|
||||
return replace_query_param(self.base_url, self.cursor_query_param, self.encode_cursor(cursor))
|
||||
|
||||
def get_previous_cursor(self):
|
||||
if not self.has_previous:
|
||||
return None
|
||||
|
||||
|
@ -661,8 +666,13 @@ class CursorPagination(BasePagination):
|
|||
offset = 0
|
||||
position = self.next_position
|
||||
|
||||
cursor = Cursor(offset=offset, reverse=True, position=position)
|
||||
return self.encode_cursor(cursor)
|
||||
return Cursor(offset=offset, reverse=True, position=position)
|
||||
|
||||
def get_previous_link(self):
|
||||
cursor = self.get_previous_cursor()
|
||||
if not cursor:
|
||||
return None
|
||||
return replace_query_param(self.base_url, self.cursor_query_param, self.encode_cursor(cursor))
|
||||
|
||||
def get_ordering(self, request, queryset, view):
|
||||
"""
|
||||
|
@ -747,8 +757,7 @@ class CursorPagination(BasePagination):
|
|||
tokens['p'] = cursor.position
|
||||
|
||||
querystring = urlparse.urlencode(tokens, doseq=True)
|
||||
encoded = b64encode(querystring.encode('ascii')).decode('ascii')
|
||||
return replace_query_param(self.base_url, self.cursor_query_param, encoded)
|
||||
return b64encode(querystring.encode('ascii')).decode('ascii')
|
||||
|
||||
def _get_position_from_instance(self, instance, ordering):
|
||||
field_name = ordering[0].lstrip('-')
|
||||
|
|
Loading…
Reference in New Issue
Block a user