From 04231ebfe53c82a5715c1650530ca58d2bf7e9c3 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Sat, 25 Jul 2020 09:30:40 +0300 Subject: [PATCH] Views: fix issue with iterators sometimes returning the wrong type. --- django_etebase/views.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/django_etebase/views.py b/django_etebase/views.py index 8a6ff85..9a71eee 100644 --- a/django_etebase/views.py +++ b/django_etebase/views.py @@ -306,11 +306,11 @@ class CollectionItemViewSet(BaseViewSet): serializer = CollectionItemRevisionSerializer(result, context=self.get_serializer_context(), many=True) - last_item = len(result) > 0 and serializer.data[-1] + iterator = serializer.data[-1]['uid'] if len(result) > 0 else None ret = { 'data': serializer.data, - 'iterator': last_item and last_item['uid'], + 'iterator': iterator, 'done': done, } return Response(ret) @@ -337,7 +337,7 @@ class CollectionItemViewSet(BaseViewSet): queryset = queryset.filter(uid__in=uids).exclude(revisions__in=revs) new_stoken = self.get_queryset_stoken(queryset) - stoken = stoken_rev and stoken_rev.uid + stoken = getattr(stoken_rev, 'uid', None) if stoken_rev is not None else None new_stoken = new_stoken or stoken serializer = self.get_serializer(queryset, many=True) @@ -519,11 +519,11 @@ class InvitationBaseViewSet(BaseViewSet): serializer = self.get_serializer(result, many=True) - last_item = len(result) > 0 and serializer.data[-1] + iterator = serializer.data[-1]['uid'] if len(result) > 0 else None ret = { 'data': serializer.data, - 'iterator': last_item and last_item['uid'], + 'iterator': iterator, 'done': done, }