From 317c492688dab64bd2537ac231d3c9621af5aa1f Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 23 Jun 2020 13:02:45 +0300 Subject: [PATCH] CollectionItem: add support for filtering collections' main items. This used to be the default, so it still is. It only affects the list endpoint, the rest all support withCollection anyway, because IDs are passed directly. --- django_etebase/views.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/django_etebase/views.py b/django_etebase/views.py index 2e4bf3c..577d923 100644 --- a/django_etebase/views.py +++ b/django_etebase/views.py @@ -254,6 +254,10 @@ class CollectionItemViewSet(BaseViewSet): def list(self, request, collection_uid=None): queryset = self.get_queryset() + + if not self.request.query_params.get('withCollection', False): + queryset = queryset.filter(parent__isnull=True) + queryset, new_stoken, done = self.filter_by_stoken_and_limit(request, queryset) serializer = self.get_serializer(queryset, many=True)