Commit befe0d40 authored by Mickaël Desfrênes's avatar Mickaël Desfrênes
Browse files

filter published collections

parent 5f44191e
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -157,6 +157,7 @@ def collections(
    limit_from: int = 0,
    limit_to: int = 2000,
    flat_list: bool = False,
    only_published=False,
) -> List[Dict]:
    """
    Return the user's collections under the parent collection
@@ -203,11 +204,14 @@ def collections(
    if flat_list:
        query_set: Union[Iterator[Collection], QuerySet] = Collection.objects.filter(
            owner=user, deleted_at__isnull=True
        )[limit_from:limit_to]
        ).order_by("pk")
    else:
        query_set: Union[Iterator[Collection], QuerySet] = Collection.objects.filter(
            owner=user, parent=parent, deleted_at__isnull=True
        )[limit_from:limit_to]
        )
    if only_published:
        query_set = query_set.filter(public_access=True)
    query_set = query_set[limit_from:limit_to]
    for item in query_set:
        data.append(serializers.collection(item, recursive=recursive))
    return data