Skip to content

Commit 863c696

Browse files
committed
fix: units added from libraries have block_type=unit
and so: * contenstore helper is_unit needs to know about this new block type * unit blocks don't have a "discussion_enabled" property * upstream sync needs to use the container type string, not its olx_tag
1 parent b248df6 commit 863c696

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

cms/djangoapps/contentstore/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def is_unit(xblock, parent_xblock=None):
7575
Returns true if the specified xblock is a vertical that is treated as a unit.
7676
A unit is a vertical that is a direct child of a sequential (aka a subsection).
7777
"""
78-
if xblock.category == 'vertical':
78+
if xblock.category == 'vertical' or xblock.category == 'unit':
7979
if parent_xblock is None:
8080
parent_xblock = get_parent_xblock(xblock)
8181
parent_category = parent_xblock.category if parent_xblock else None

cms/djangoapps/contentstore/xblock_storage_handlers/view_handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ def create_xblock_info( # lint-amnesty, pylint: disable=too-many-statements
12781278
xblock_info.update(_get_gating_info(course, xblock))
12791279
if is_xblock_unit:
12801280
# if xblock is a Unit we add the discussion_enabled option
1281-
xblock_info["discussion_enabled"] = xblock.discussion_enabled
1281+
xblock_info["discussion_enabled"] = getattr(xblock, 'discussion_enabled', False)
12821282

12831283
# Also add upstream info
12841284
xblock_info["upstream_info"] = UpstreamLink.try_get_for_block(xblock).to_json()

cms/lib/xblock/upstream_sync.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def get_for_block(cls, downstream: XBlock) -> t.Self:
191191
container_meta = lib_api.get_container(upstream_key)
192192
except lib_api.ContentLibraryContainerNotFound as exc:
193193
raise BadUpstream(_("Linked upstream library container was not found in the system")) from exc
194-
expected_downstream_block_type = container_meta.container_type.olx_tag
194+
expected_downstream_block_type = container_meta.container_type.value
195195
version_available = container_meta.published_version_num
196196

197197
if downstream_type != expected_downstream_block_type:

0 commit comments

Comments
 (0)