Commit 24189378 by Don Mitchell

Merge pull request #1864 from MITx/bug/christina/export

Don't try to export orphaned draft items.
parents 91d84c02 8c336ef9
...@@ -386,6 +386,10 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase): ...@@ -386,6 +386,10 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
draft_store.clone_item(vertical.location, vertical.location) draft_store.clone_item(vertical.location, vertical.location)
# We had a bug where orphaned draft nodes caused export to fail. This is here to cover that case.
draft_store.clone_item(vertical.location, Location(['i4x', 'edX', 'full',
'vertical', 'no_references', 'draft']))
for child in vertical.get_children(): for child in vertical.get_children():
draft_store.clone_item(child.location, child.location) draft_store.clone_item(child.location, child.location)
......
...@@ -50,12 +50,14 @@ def export_to_xml(modulestore, contentstore, course_location, root_dir, course_d ...@@ -50,12 +50,14 @@ def export_to_xml(modulestore, contentstore, course_location, root_dir, course_d
draft_course_dir = export_fs.makeopendir('drafts') draft_course_dir = export_fs.makeopendir('drafts')
for draft_vertical in draft_verticals: for draft_vertical in draft_verticals:
parent_locs = draft_modulestore.get_parent_locations(draft_vertical.location, course.location.course_id) parent_locs = draft_modulestore.get_parent_locations(draft_vertical.location, course.location.course_id)
logging.debug('parent_locs = {0}'.format(parent_locs)) # Don't try to export orphaned items.
draft_vertical.xml_attributes['parent_sequential_url'] = Location(parent_locs[0]).url() if len(parent_locs) > 0:
sequential = modulestore.get_item(Location(parent_locs[0])) logging.debug('parent_locs = {0}'.format(parent_locs))
index = sequential.children.index(draft_vertical.location.url()) draft_vertical.xml_attributes['parent_sequential_url'] = Location(parent_locs[0]).url()
draft_vertical.xml_attributes['index_in_children_list'] = str(index) sequential = modulestore.get_item(Location(parent_locs[0]))
draft_vertical.export_to_xml(draft_course_dir) index = sequential.children.index(draft_vertical.location.url())
draft_vertical.xml_attributes['index_in_children_list'] = str(index)
draft_vertical.export_to_xml(draft_course_dir)
def export_extra_content(export_fs, modulestore, course_location, category_type, dirname, file_suffix=''): def export_extra_content(export_fs, modulestore, course_location, category_type, dirname, file_suffix=''):
......
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