mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-05 04:50:12 +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):
|
def get_page_size(self, request):
|
||||||
return self.page_size
|
return self.page_size
|
||||||
|
|
||||||
def get_next_link(self):
|
def get_next_cursor(self):
|
||||||
if not self.has_next:
|
if not self.has_next:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -613,10 +613,15 @@ class CursorPagination(BasePagination):
|
||||||
offset = self.cursor.offset + self.page_size
|
offset = self.cursor.offset + self.page_size
|
||||||
position = self.previous_position
|
position = self.previous_position
|
||||||
|
|
||||||
cursor = Cursor(offset=offset, reverse=False, position=position)
|
return Cursor(offset=offset, reverse=False, position=position)
|
||||||
return self.encode_cursor(cursor)
|
|
||||||
|
|
||||||
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:
|
if not self.has_previous:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -661,8 +666,13 @@ class CursorPagination(BasePagination):
|
||||||
offset = 0
|
offset = 0
|
||||||
position = self.next_position
|
position = self.next_position
|
||||||
|
|
||||||
cursor = Cursor(offset=offset, reverse=True, position=position)
|
return Cursor(offset=offset, reverse=True, position=position)
|
||||||
return self.encode_cursor(cursor)
|
|
||||||
|
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):
|
def get_ordering(self, request, queryset, view):
|
||||||
"""
|
"""
|
||||||
|
@ -747,8 +757,7 @@ class CursorPagination(BasePagination):
|
||||||
tokens['p'] = cursor.position
|
tokens['p'] = cursor.position
|
||||||
|
|
||||||
querystring = urlparse.urlencode(tokens, doseq=True)
|
querystring = urlparse.urlencode(tokens, doseq=True)
|
||||||
encoded = b64encode(querystring.encode('ascii')).decode('ascii')
|
return b64encode(querystring.encode('ascii')).decode('ascii')
|
||||||
return replace_query_param(self.base_url, self.cursor_query_param, encoded)
|
|
||||||
|
|
||||||
def _get_position_from_instance(self, instance, ordering):
|
def _get_position_from_instance(self, instance, ordering):
|
||||||
field_name = ordering[0].lstrip('-')
|
field_name = ordering[0].lstrip('-')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user