Commit f8358057 by Jonathan Piacenti

Revert "Provide a path for default xml to load upon creation."

This reverts commit 76bf8031.
parent 76bf8031
......@@ -55,16 +55,6 @@ from .utils import XBlockWithChildrenFragmentsMixin
log = logging.getLogger(__name__)
def get_xml_content(block):
"""
Because we get the XML content dynamically, we can't use the String field's
default kwarg to fall back on. Therefore any time we need to access the
xml_content's value, we need to do it through this function.
"""
default = getattr(block, 'default_xml_content', '')
value = getattr(block, 'xml_content', '')
return value or default
# Classes ###########################################################
class LightChildrenMixin(XBlockWithChildrenFragmentsMixin):
......@@ -93,7 +83,7 @@ class LightChildrenMixin(XBlockWithChildrenFragmentsMixin):
log.debug('parse_xml called')
block = runtime.construct_xblock_from_class(cls, keys)
cls.init_block_from_node(block, node, node.items())
block.xml_content = get_xml_content(block) or etree.tostring(node)
block.xml_content = getattr(block, 'xml_content', '') or etree.tostring(node)
return block
@classmethod
......@@ -136,12 +126,11 @@ class LightChildrenMixin(XBlockWithChildrenFragmentsMixin):
Load light children from the `xml_content` attribute
"""
self.light_children = []
xml_content = get_xml_content(self)
if not xml_content:
if not hasattr(self, 'xml_content') or not self.xml_content:
return
parser = etree.XMLParser(remove_comments=True)
node = etree.parse(StringIO(xml_content), parser=parser).getroot()
node = etree.parse(StringIO(self.xml_content), parser=parser).getroot()
LightChildrenMixin.init_block_from_node(self, node, node.items())
def get_children_objects(self):
......
......@@ -33,7 +33,7 @@ from xblock.core import XBlock
from xblock.fields import Boolean, Scope, String, Integer, Float, List
from xblock.fragment import Fragment
from .light_children import XBlockWithLightChildren, get_xml_content
from .light_children import XBlockWithLightChildren
from .title import TitleBlock
from .header import SharedHeaderBlock
from .html import HTMLBlock
......@@ -71,7 +71,6 @@ class MentoringBlock(XBlockWithLightChildren, StepParentMixin):
enforce_dependency = Boolean(help="Should the next step be the current block to complete?",
default=False, scope=Scope.content, enforce_type=True)
display_submit = Boolean(help="Allow to submit current block?", default=True, scope=Scope.content)
# See get_xml_content from light_children.
xml_content = String(help="XML content", default='', scope=Scope.content)
weight = Float(help="Defines the maximum total grade of the block.",
default=1, scope=Scope.content, enforce_type=True)
......@@ -374,7 +373,7 @@ class MentoringBlock(XBlockWithLightChildren, StepParentMixin):
fragment = Fragment()
fragment.add_content(render_template('templates/html/mentoring_edit.html', {
'self': self,
'xml_content': get_xml_content(self)
'xml_content': self.xml_content or self.default_xml_content,
}))
fragment.add_javascript_url(
self.runtime.local_resource_url(self, 'public/js/mentoring_edit.js'))
......
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