From 62a90db1a73a5419e63d10845efed9a24f2f27b5 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 27 Mar 2015 14:10:46 -0400 Subject: [PATCH] Extract a pure-XBlock version of StudioEditingModule --- common/lib/xmodule/xmodule/studio_editable.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/common/lib/xmodule/xmodule/studio_editable.py b/common/lib/xmodule/xmodule/studio_editable.py index 5b173ecbab..28e44d4bcc 100644 --- a/common/lib/xmodule/xmodule/studio_editable.py +++ b/common/lib/xmodule/xmodule/studio_editable.py @@ -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.