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:
@@ -309,8 +309,15 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
|
||||
# add private to list of children
|
||||
sequential = module_store.get_item(Location(['i4x', 'edX', 'full',
|
||||
'sequential', 'Administrivia_and_Circuit_Elements', None]))
|
||||
module_store.update_children(sequential.location, sequential.children + [private_vertical.location.url()])
|
||||
private_location_no_draft = private_vertical.location._replace(revision=None)
|
||||
module_store.update_children(sequential.location, sequential.children +
|
||||
[private_location_no_draft.url()])
|
||||
|
||||
# read back the sequential, to make sure we have a pointer to
|
||||
sequential = module_store.get_item(Location(['i4x', 'edX', 'full',
|
||||
'sequential', 'Administrivia_and_Circuit_Elements', None]))
|
||||
|
||||
self.assertIn(private_location_no_draft.url(), sequential.children)
|
||||
|
||||
print 'Exporting to tempdir = {0}'.format(root_dir)
|
||||
|
||||
@@ -354,10 +361,12 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
|
||||
items = module_store.get_items(Location(['i4x', 'edX', 'full', 'vertical', None]))
|
||||
self.assertGreater(len(items), 0)
|
||||
for descriptor in items:
|
||||
print "Checking {0}....".format(descriptor.location.url())
|
||||
non_draft_loc = descriptor.location._replace(revision=None)
|
||||
resp = self.client.get(reverse('edit_unit', kwargs={'location': non_draft_loc.url()}))
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
# don't try to look at private verticals. Right now we're running
|
||||
# the service in non-draft aware
|
||||
if hasattr(descriptor, 'is_draft'):
|
||||
print "Checking {0}....".format(descriptor.location.url())
|
||||
resp = self.client.get(reverse('edit_unit', kwargs={'location': descriptor.location.url()}))
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
|
||||
# verify that we have the content in the draft store as well
|
||||
vertical = draft_store.get_item(Location(['i4x', 'edX', 'full',
|
||||
|
||||
@@ -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