Commit 652e2aa2 by Victor Shnayder

fix for inheriting metadata bug

* problem was on import to json--got all the metadata,
  but didn't preserve the _inherited_metadata
* added own_metadata property, use it instead
parent b63f05b6
......@@ -41,6 +41,9 @@ class ImportSystem(XMLParsingSystem, MakoDescriptorSystem):
self.used_slugs = set()
def process_xml(xml):
"""Takes an xml string, and returns a XModuleDescriptor created from
that xml.
"""
try:
# VS[compat]
# TODO (cpennington): Remove this once all fall 2012 courses
......
......@@ -35,6 +35,8 @@ def import_from_xml(store, data_dir, course_dirs=None, eager=True,
store.update_item(module.location, module.definition['data'])
if 'children' in module.definition:
store.update_children(module.location, module.definition['children'])
store.update_metadata(module.location, dict(module.metadata))
# NOTE: It's important to use own_metadata here to avoid writing
# inherited metadata everywhere.
store.update_metadata(module.location, dict(module.own_metadata))
return module_store
......@@ -358,6 +358,14 @@ class XModuleDescriptor(Plugin, HTMLSnippet):
self._child_instances = None
self._inherited_metadata = set()
@property
def own_metadata(self):
"""
Return the metadata that is not inherited, but was defined on this module.
"""
return dict((k,v) for k,v in self.metadata.items()
if k not in self._inherited_metadata)
def inherit_metadata(self, metadata):
"""
Updates this module with metadata inherited from a containing module.
......
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