fix: Issues with get container children [FC-0083] (#36686)
* Fix published param to support strings * Add published_display_name to children response
This commit is contained in:
@@ -57,6 +57,7 @@ class LibraryXBlockMetadata(PublishableItem):
|
||||
modified=draft.created,
|
||||
draft_version_num=draft.version_num,
|
||||
published_version_num=published.version_num if published else None,
|
||||
published_display_name=published.title if published else None,
|
||||
last_published=None if last_publish_log is None else last_publish_log.published_at,
|
||||
published_by=published_by,
|
||||
last_draft_created=last_draft_created,
|
||||
|
||||
@@ -110,7 +110,6 @@ class ContainerMetadata(PublishableItem):
|
||||
container_key: LibraryContainerLocator
|
||||
container_type: ContainerType
|
||||
container_pk: int
|
||||
published_display_name: str | None
|
||||
|
||||
@classmethod
|
||||
def from_container(cls, library_key, container: Container, associated_collections=None):
|
||||
|
||||
@@ -191,6 +191,7 @@ class PublishableItem(LibraryItem):
|
||||
"""
|
||||
draft_version_num: int
|
||||
published_version_num: int | None = None
|
||||
published_display_name: str | None
|
||||
last_published: datetime | None = None
|
||||
# The username of the user who last published this.
|
||||
published_by: str = ""
|
||||
|
||||
@@ -178,7 +178,7 @@ class LibraryContainerChildrenView(GenericAPIView):
|
||||
}
|
||||
]
|
||||
"""
|
||||
published = request.GET.get('published', False)
|
||||
published = request.GET.get('published', 'false').lower() == 'true'
|
||||
api.require_permission_for_library_key(
|
||||
container_key.lib_key,
|
||||
request.user,
|
||||
|
||||
@@ -138,6 +138,7 @@ class PublishableItemSerializer(serializers.Serializer):
|
||||
"""
|
||||
id = serializers.SerializerMethodField()
|
||||
display_name = serializers.CharField()
|
||||
published_display_name = serializers.CharField(required=False)
|
||||
tags_count = serializers.IntegerField(read_only=True)
|
||||
last_published = serializers.DateTimeField(format=DATETIME_FORMAT, read_only=True)
|
||||
published_by = serializers.CharField(read_only=True)
|
||||
|
||||
@@ -327,6 +327,7 @@ class ContentLibrariesTestCase(ContentLibrariesRestApiTest):
|
||||
block_data["has_unpublished_changes"] = False
|
||||
block_data["last_published"] = publish_date.isoformat().replace('+00:00', 'Z')
|
||||
block_data["published_by"] = "Bob"
|
||||
block_data["published_display_name"] = "Blank Problem"
|
||||
self.assertDictContainsEntries(self._get_library_block(block_id), block_data)
|
||||
assert self._get_library_blocks(lib_id)['results'] == [block_data]
|
||||
|
||||
@@ -440,6 +441,7 @@ class ContentLibrariesTestCase(ContentLibrariesRestApiTest):
|
||||
block_data["has_unpublished_changes"] = False
|
||||
block_data["last_published"] = publish_date.isoformat().replace('+00:00', 'Z')
|
||||
block_data["published_by"] = "Bob"
|
||||
block_data["published_display_name"] = "Text"
|
||||
self.assertDictContainsEntries(self._get_library_block(block_id), block_data)
|
||||
assert self._get_library_blocks(lib_id)['results'] == [block_data]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user