fix: Publish components/container in legacy libraries migration (#37644)
- Fix the issue described in https://github.com/openedx/frontend-app-authoring/issues/2626 - Publish components and containers after migrate
This commit is contained in:
@@ -1077,7 +1077,8 @@ def _migrate_container(
|
||||
entity_id=container.container_pk,
|
||||
version_num=container.draft_version_num,
|
||||
)
|
||||
return authoring_api.create_next_container_version(
|
||||
|
||||
container_publishable_entity_version = authoring_api.create_next_container_version(
|
||||
container.container_pk,
|
||||
title=title,
|
||||
entity_rows=[
|
||||
@@ -1089,6 +1090,17 @@ def _migrate_container(
|
||||
container_version_cls=container_type.container_model_classes[1],
|
||||
).publishable_entity_version
|
||||
|
||||
# Publish the container
|
||||
# Call post publish events synchronously to avoid
|
||||
# an error when calling `wait_for_post_publish_events`
|
||||
# inside a celery task.
|
||||
libraries_api.publish_container_changes(
|
||||
container.container_key,
|
||||
context.created_by,
|
||||
call_post_publish_events_sync=True,
|
||||
)
|
||||
return container_publishable_entity_version
|
||||
|
||||
|
||||
def _migrate_component(
|
||||
*,
|
||||
@@ -1153,6 +1165,12 @@ def _migrate_component(
|
||||
authoring_api.create_component_version_content(
|
||||
component_version.pk, content_pk, key=new_path
|
||||
)
|
||||
|
||||
# Publish the component
|
||||
libraries_api.publish_component_changes(
|
||||
libraries_api.library_component_usage_key(context.target_library_key, component),
|
||||
context.created_by,
|
||||
)
|
||||
return component_version.publishable_entity_version
|
||||
|
||||
|
||||
|
||||
@@ -440,6 +440,9 @@ class TestMigrateFromModulestore(ModuleStoreTestCase):
|
||||
"problem", result.componentversion.component.component_type.name
|
||||
)
|
||||
|
||||
# The component is published
|
||||
self.assertFalse(result.componentversion.component.versioning.has_unpublished_changes)
|
||||
|
||||
def test_migrate_component_with_static_content(self):
|
||||
"""
|
||||
Test _migrate_component with static file content
|
||||
@@ -897,6 +900,8 @@ class TestMigrateFromModulestore(ModuleStoreTestCase):
|
||||
|
||||
container_version = result.containerversion
|
||||
self.assertEqual(container_version.title, f"Test {block_type.title()}")
|
||||
# The container is published
|
||||
self.assertFalse(authoring_api.contains_unpublished_changes(container_version.container.pk))
|
||||
|
||||
def test_migrate_container_replace_existing_false(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user