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.
master
Tom Hacohen 4 years ago
parent 291ebaa3f7
commit 317c492688

@ -254,6 +254,10 @@ class CollectionItemViewSet(BaseViewSet):
def list(self, request, collection_uid=None): def list(self, request, collection_uid=None):
queryset = self.get_queryset() 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) queryset, new_stoken, done = self.filter_by_stoken_and_limit(request, queryset)
serializer = self.get_serializer(queryset, many=True) serializer = self.get_serializer(queryset, many=True)

Loading…
Cancel
Save