Commit 07f64abb by Arthur Barrett

Refactored init method.

parent a982ebbb
...@@ -71,7 +71,8 @@ class AnnotatableModule(XModule): ...@@ -71,7 +71,8 @@ class AnnotatableModule(XModule):
return data_attrs return data_attrs
def _render_content(self): def _render_content(self):
""" Renders annotatable content by transforming spans and adding discussions. """ """ Renders annotatable content with annotation spans and returns HTML. """
xmltree = etree.fromstring(self.content) xmltree = etree.fromstring(self.content)
xmltree.tag = 'div' xmltree.tag = 'div'
...@@ -110,20 +111,16 @@ class AnnotatableModule(XModule): ...@@ -110,20 +111,16 @@ class AnnotatableModule(XModule):
instance_state, shared_state, **kwargs) instance_state, shared_state, **kwargs)
xmltree = etree.fromstring(self.definition['data']) xmltree = etree.fromstring(self.definition['data'])
discussion_id = '' root_attr = {}
if 'discussion' in xmltree.attrib: for key in ('discussion', 'help_text'):
discussion_id = xmltree.get('discussion') if key in xmltree.attrib:
del xmltree.attrib['discussion'] root_attr[key] = xmltree.get(key)
del xmltree.attrib[key]
help_text = ''
if 'help_text' in xmltree.attrib:
help_text = xmltree.get('help_text')
del xmltree.attrib['help_text']
self.content = etree.tostring(xmltree, encoding='unicode') self.content = etree.tostring(xmltree, encoding='unicode')
self.element_id = self.location.html_id() self.element_id = self.location.html_id()
self.discussion_id = discussion_id self.discussion_id = root_attr['discussion']
self.help_text = help_text self.help_text = root_attr['help_text']
class AnnotatableDescriptor(RawDescriptor): class AnnotatableDescriptor(RawDescriptor):
module_class = AnnotatableModule module_class = AnnotatableModule
......
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