Commit 62a90db1 by Calen Pennington

Extract a pure-XBlock version of StudioEditingModule

parent ee401f15
...@@ -4,13 +4,13 @@ Mixin to support editing in Studio. ...@@ -4,13 +4,13 @@ Mixin to support editing in Studio.
from xmodule.x_module import module_attr, STUDENT_VIEW, AUTHOR_VIEW 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 This class is only intended to be used with an XBlock!
self.descriptor and self.system.
""" """
has_author_view = True
def render_children(self, context, fragment, can_reorder=False, can_add=False): def render_children(self, context, fragment, can_reorder=False, can_add=False):
""" """
...@@ -19,15 +19,14 @@ class StudioEditableModule(object): ...@@ -19,15 +19,14 @@ class StudioEditableModule(object):
""" """
contents = [] 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: if can_reorder:
context['reorderable_items'].add(child.location) context['reorderable_items'].add(child.location)
child_module = self.system.get_module(child) # pylint: disable=no-member rendered_child = child.render(StudioEditableModule.get_preview_view_name(child), context)
rendered_child = child_module.render(StudioEditableModule.get_preview_view_name(child_module), context)
fragment.add_frag_resources(rendered_child) fragment.add_frag_resources(rendered_child)
contents.append({ contents.append({
'id': child.location.to_deprecated_string(), 'id': unicode(child.location),
'content': rendered_child.content 'content': rendered_child.content
}) })
...@@ -46,6 +45,9 @@ class StudioEditableModule(object): ...@@ -46,6 +45,9 @@ class StudioEditableModule(object):
return AUTHOR_VIEW if hasattr(block, AUTHOR_VIEW) else STUDENT_VIEW return AUTHOR_VIEW if hasattr(block, AUTHOR_VIEW) else STUDENT_VIEW
StudioEditableModule = StudioEditableBlock
class StudioEditableDescriptor(object): class StudioEditableDescriptor(object):
""" """
Helper mixin for supporting Studio editing of xmodules. Helper mixin for supporting Studio editing of xmodules.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment