Skip to content

Commit

Permalink
fix: use PublishableEntity.key instead of IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
pomegranited committed Aug 28, 2024
1 parent 7ec9ba5 commit 0e15dd0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions openedx_learning/apps/authoring/collections/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ def remove_from_collections(
return total_deleted


def get_object_collections(object_id: int) -> QuerySet[Collection]:
def get_object_collections(object_key: str) -> QuerySet[Collection]:
"""
Get all collections associated with a given PublishableEntity.
Get all collections associated with a given PublishableEntity.key.
Only enabled collections are returned.
"""
entity = PublishableEntity.objects.get(pk=object_id)
entity = PublishableEntity.objects.get(key=object_key)
return entity.collections.filter(enabled=True).order_by("pk")


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def test_get_object_collections(self):
Tests fetching the enabled collections which contain a given object.
"""
collections = collection_api.get_object_collections(
self.published_entity.id,
self.published_entity.key,
)
assert list(collections) == [
self.collection1,
Expand Down

0 comments on commit 0e15dd0

Please sign in to comment.