From efe245739b9cf1966c14eb341529ec609098e5e7 Mon Sep 17 00:00:00 2001 From: Marnanel Thurman Date: Thu, 6 Sep 2018 16:08:43 +0100 Subject: [PATCH] Fixed call to __super__.__init__() in CollectionResponse. Re-added _make_index_page. --- django_kepi/responses.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/django_kepi/responses.py b/django_kepi/responses.py index 0c0ab91..d2c84cc 100644 --- a/django_kepi/responses.py +++ b/django_kepi/responses.py @@ -1,6 +1,7 @@ import django.http import json import django_kepi +import urllib PAGE_LENGTH = 50 PAGE_FIELD = 'page' @@ -37,7 +38,7 @@ class CollectionResponse(ActivityObjectResponse): items, request): - super().__init__(self) + super().__init__() self.items = items # assert that self.items is ordered @@ -92,3 +93,29 @@ class CollectionResponse(ActivityObjectResponse): def _transform_object(self, obj): return str(obj) + def _make_query_page( + self, + request, + page_number, + ): + + fields = dict(request.GET) + + if page_number is None: + if PAGE_FIELD in fields: + del fields[PAGE_FIELD] + else: + fields[PAGE_FIELD] = page_number + + encoded = urllib.parse.urlencode(fields) + + if encoded!='': + encoded = '?'+encoded + + return '{}://{}{}{}'.format( + request.scheme, + request.get_host(), + request.path, + encoded, + ) +