refactor: replace displayable_blocks with child
This removes the "displayable_blocks" property and replaces all the usages with the "child" property.
This commit is contained in:
@@ -403,7 +403,7 @@ class XBlockShim:
|
||||
warnings.warn("get_display_blocks() is deprecated.", DeprecationWarning, stacklevel=2)
|
||||
blocks = []
|
||||
for child in self.get_children():
|
||||
blocks.extend(child.displayable_blocks())
|
||||
blocks.append(child)
|
||||
return blocks
|
||||
|
||||
def displayable_items(self):
|
||||
|
||||
@@ -399,13 +399,13 @@ class LibraryContentBlock(
|
||||
# 500-response.
|
||||
logger.error('Skipping display for child block that is None')
|
||||
continue
|
||||
for displayable in child.displayable_blocks():
|
||||
rendered_child = displayable.render(STUDENT_VIEW, child_context)
|
||||
fragment.add_fragment_resources(rendered_child)
|
||||
contents.append({
|
||||
'id': str(displayable.location),
|
||||
'content': rendered_child.content,
|
||||
})
|
||||
|
||||
rendered_child = child.render(STUDENT_VIEW, child_context)
|
||||
fragment.add_fragment_resources(rendered_child)
|
||||
contents.append({
|
||||
'id': str(child.location),
|
||||
'content': rendered_child.content,
|
||||
})
|
||||
|
||||
fragment.add_content(self.runtime.service(self, 'mako').render_template('vert_module.html', {
|
||||
'items': contents,
|
||||
|
||||
@@ -91,7 +91,6 @@ class ConditionalFactory:
|
||||
child_descriptor.visible_to_staff_only = False
|
||||
child_descriptor._xmodule.student_view.return_value = Fragment(content='<p>This is a secret</p>') # lint-amnesty, pylint: disable=protected-access
|
||||
child_descriptor.student_view = child_descriptor._xmodule.student_view # lint-amnesty, pylint: disable=protected-access
|
||||
child_descriptor.displayable_blocks.return_value = [child_descriptor]
|
||||
child_descriptor.runtime = descriptor_system
|
||||
child_descriptor.xmodule_runtime = get_test_system()
|
||||
child_descriptor.render = lambda view, context=None: descriptor_system.render(child_descriptor, view, context)
|
||||
|
||||
@@ -531,17 +531,10 @@ class XModuleMixin(XModuleFields, XBlock):
|
||||
"""
|
||||
blocks = []
|
||||
for child in self.get_children():
|
||||
blocks.extend(child.displayable_blocks())
|
||||
blocks.append(child)
|
||||
|
||||
return blocks
|
||||
|
||||
def displayable_blocks(self):
|
||||
"""
|
||||
Returns list of displayable modules contained by this module. If this
|
||||
module is visible, should return [self].
|
||||
"""
|
||||
return [self]
|
||||
|
||||
def get_child_by(self, selector):
|
||||
"""
|
||||
Return a child XBlock that matches the specified selector
|
||||
|
||||
Reference in New Issue
Block a user