Skip to content

Commit

Permalink
fix(collections): add collection_content_objects templatetag
Browse files Browse the repository at this point in the history
This templatetag allows to list collectionobjects an instance is
connected to.
  • Loading branch information
b1rger committed Jan 25, 2024
1 parent 88543d2 commit 865754a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions apis_core/collections/templatetags/apis_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,15 @@ def collection_object_parent_by_id(context, obj, collectionobject_id):
"""
collectionobject = SkosCollectionContentObject.objects.get(pk=collectionobject_id)
return collection_object_parent(context, obj, collectionobject)


@register.simple_tag(takes_context=True)
def collection_content_objects(context, obj, collectionids=None):
content_type = ContentType.objects.get_for_model(obj)
sccos = SkosCollectionContentObject.objects.filter(
content_type=content_type, object_id=obj.id
)
if collectionids is not None:
ids = collectionids.split(",")
sccos = sccos.filter(collection__id__in=ids)
return sccos

0 comments on commit 865754a

Please sign in to comment.