Extract a pure-XBlock version of StudioEditingModule
This commit is contained in:
@@ -4,13 +4,13 @@ Mixin to support editing in Studio.
|
||||
from xmodule.x_module import module_attr, STUDENT_VIEW, AUTHOR_VIEW
|
||||
|
||||
|
||||
class StudioEditableModule(object):
|
||||
class StudioEditableBlock(object):
|
||||
"""
|
||||
Helper methods for supporting Studio editing of xmodules.
|
||||
Helper methods for supporting Studio editing of XBlocks.
|
||||
|
||||
This class is only intended to be used with an XModule, as it assumes the existence of
|
||||
self.descriptor and self.system.
|
||||
This class is only intended to be used with an XBlock!
|
||||
"""
|
||||
has_author_view = True
|
||||
|
||||
def render_children(self, context, fragment, can_reorder=False, can_add=False):
|
||||
"""
|
||||
@@ -19,15 +19,14 @@ class StudioEditableModule(object):
|
||||
"""
|
||||
contents = []
|
||||
|
||||
for child in self.descriptor.get_children(): # pylint: disable=no-member
|
||||
for child in self.get_children(): # pylint: disable=no-member
|
||||
if can_reorder:
|
||||
context['reorderable_items'].add(child.location)
|
||||
child_module = self.system.get_module(child) # pylint: disable=no-member
|
||||
rendered_child = child_module.render(StudioEditableModule.get_preview_view_name(child_module), context)
|
||||
rendered_child = child.render(StudioEditableModule.get_preview_view_name(child), context)
|
||||
fragment.add_frag_resources(rendered_child)
|
||||
|
||||
contents.append({
|
||||
'id': child.location.to_deprecated_string(),
|
||||
'id': unicode(child.location),
|
||||
'content': rendered_child.content
|
||||
})
|
||||
|
||||
@@ -46,6 +45,9 @@ class StudioEditableModule(object):
|
||||
return AUTHOR_VIEW if hasattr(block, AUTHOR_VIEW) else STUDENT_VIEW
|
||||
|
||||
|
||||
StudioEditableModule = StudioEditableBlock
|
||||
|
||||
|
||||
class StudioEditableDescriptor(object):
|
||||
"""
|
||||
Helper mixin for supporting Studio editing of xmodules.
|
||||
|
||||
Reference in New Issue
Block a user