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.
This commit is contained in:
Navin Karkera
2025-08-04 11:35:12 +05:30
committed by GitHub
parent c2a86534e6
commit 103a152c36

View File

@@ -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