From 103a152c36dc35a757b9d081e719c64b5606c8a5 Mon Sep 17 00:00:00 2001 From: Navin Karkera Date: Mon, 4 Aug 2025 11:35:12 +0530 Subject: [PATCH] feat: disallow adding children to containers imported from library (#37088) Updates `childAddable` action in xblocks that have upstream link to stop users from updating imported sections and subsections. --- .../contentstore/xblock_storage_handlers/view_handlers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cms/djangoapps/contentstore/xblock_storage_handlers/view_handlers.py b/cms/djangoapps/contentstore/xblock_storage_handlers/view_handlers.py index d75d481ad6..a7ae0e518e 100644 --- a/cms/djangoapps/contentstore/xblock_storage_handlers/view_handlers.py +++ b/cms/djangoapps/contentstore/xblock_storage_handlers/view_handlers.py @@ -1304,7 +1304,11 @@ def create_xblock_info( # lint-amnesty, pylint: disable=too-many-statements # Update with gating info xblock_info.update(_get_gating_info(course, xblock)) # Also add upstream info - xblock_info["upstream_info"] = UpstreamLink.try_get_for_block(xblock, log_error=False).to_json() + upstream_info = UpstreamLink.try_get_for_block(xblock, log_error=False).to_json() + xblock_info["upstream_info"] = upstream_info + # Disable adding or removing children component if xblock is imported from library + if upstream_info["upstream_ref"]: + xblock_actions["childAddable"] = False if is_xblock_unit: # if xblock is a Unit we add the discussion_enabled option xblock_info["discussion_enabled"] = xblock.discussion_enabled