Skip to content

Commit

Permalink
feat: adds component_key to LibraryXBlockMetadata
Browse files Browse the repository at this point in the history
and its serializer so the frontend has component_keys for use with the
/collection/contents endpoint.
  • Loading branch information
pomegranited committed Aug 28, 2024
1 parent e16a99c commit 383ed50
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions openedx/core/djangoapps/content_libraries/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ class LibraryXBlockMetadata:
last_published = attr.ib(default=None, type=datetime)
has_unpublished_changes = attr.ib(False)
tags_count = attr.ib(0)
component_key = attr.ib(default=None, type=str)

@classmethod
def from_component(cls, library_key, component):
Expand All @@ -215,6 +216,7 @@ def from_component(cls, library_key, component):
last_publish_log = component.versioning.last_publish_log

return cls(
component_key=component.key,
usage_key=LibraryUsageLocatorV2(
library_key,
component.component_type.name,
Expand Down
3 changes: 3 additions & 0 deletions openedx/core/djangoapps/content_libraries/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ class LibraryXBlockMetadataSerializer(serializers.Serializer):
slug = serializers.CharField(write_only=True)
tags_count = serializers.IntegerField(read_only=True)

# Key for the Component / PublishableEntity associated with this XBlock
component_key = serializers.CharField(read_only=True)


class LibraryXBlockTypeSerializer(serializers.Serializer):
"""
Expand Down

0 comments on commit 383ed50

Please sign in to comment.