actually we need to start the draft content export from the sequentials. This is because we need the child pointers to the draft verticals. For private items, if we don't do this, then we'll loose those pointers
This commit is contained in:
@@ -55,13 +55,23 @@ def export_to_xml(modulestore, contentstore, course_location, root_dir, course_d
|
||||
# should we change the application, then this assumption will no longer
|
||||
# be valid
|
||||
if draft_modulestore is not None:
|
||||
draft_items = draft_modulestore.get_items([None, course_location.org, course_location.course,
|
||||
draft_verticals = draft_modulestore.get_items([None, course_location.org, course_location.course,
|
||||
'vertical', None, 'draft'])
|
||||
|
||||
if len(draft_items)>0:
|
||||
if len(draft_verticals)>0:
|
||||
# now we have to go find every parent for each module and export from that point. We have
|
||||
# to initiate the export from the sequence since we need the child pointers to private
|
||||
# verticals. These will get filtered out from the export of the non-draft store.
|
||||
sequential_locs = []
|
||||
for draft_vertical in draft_verticals:
|
||||
parent_locs = draft_modulestore.get_parent_locations(draft_vertical.location, course.location.course_id)
|
||||
if parent_locs[0] not in sequential_locs:
|
||||
sequential_locs.append(parent_locs[0])
|
||||
|
||||
draft_course_dir = export_fs.makeopendir('drafts')
|
||||
for draft_item in draft_items:
|
||||
draft_item.export_to_xml(draft_course_dir)
|
||||
for sequential_loc in sequential_locs:
|
||||
sequential = draft_modulestore.get_item(sequential_loc)
|
||||
sequential.export_to_xml(draft_course_dir)
|
||||
|
||||
|
||||
def export_extra_content(export_fs, modulestore, course_location, category_type, dirname, file_suffix=''):
|
||||
|
||||
@@ -364,7 +364,7 @@ def import_course_draft(xml_module_store, store, course_data_path, static_conten
|
||||
)
|
||||
|
||||
# now walk the /vertical directory where each file in there will be a draft copy of the Vertical
|
||||
for dirname, dirnames, filenames in os.walk(draft_dir + "/vertical"):
|
||||
for dirname, dirnames, filenames in os.walk(draft_dir + "/sequential"):
|
||||
for filename in filenames:
|
||||
module_path = os.path.join(dirname, filename)
|
||||
with open(module_path) as f:
|
||||
@@ -373,7 +373,8 @@ def import_course_draft(xml_module_store, store, course_data_path, static_conten
|
||||
descriptor = system.process_xml(xml)
|
||||
|
||||
def _import_module(module):
|
||||
module.location = module.location._replace(revision='draft')
|
||||
if module.location.category != 'sequential':
|
||||
module.location = module.location._replace(revision='draft')
|
||||
import_module(module, store, course_data_path, static_content_store, allow_not_found=True)
|
||||
for child in module.get_children():
|
||||
_import_module(child)
|
||||
|
||||
Reference in New Issue
Block a user