init work. Export the 'draft' store under a distinct folder in the export. TBD: do the import from that directory as well.
This commit is contained in:
@@ -1426,7 +1426,7 @@ def generate_export_course(request, org, course, name):
|
||||
|
||||
logging.debug('root = {0}'.format(root_dir))
|
||||
|
||||
export_to_xml(modulestore('direct'), contentstore(), loc, root_dir, name)
|
||||
export_to_xml(modulestore('direct'), contentstore(), loc, root_dir, name, modulestore())
|
||||
#filename = root_dir / name + '.tar.gz'
|
||||
|
||||
logging.debug('tar file being generated at {0}'.format(export_file.name))
|
||||
|
||||
@@ -183,6 +183,10 @@ class DraftModuleStore(ModuleStoreBase):
|
||||
metadata.update(draft.metadata)
|
||||
metadata['published_date'] = tuple(datetime.utcnow().timetuple())
|
||||
metadata['published_by'] = published_by_id
|
||||
|
||||
if 'is_draft' in metadata:
|
||||
del metadata['is_draft']
|
||||
|
||||
super(DraftModuleStore, self).update_item(location, draft.definition.get('data', {}))
|
||||
super(DraftModuleStore, self).update_children(location, draft.definition.get('children', []))
|
||||
super(DraftModuleStore, self).update_metadata(location, metadata)
|
||||
|
||||
@@ -5,7 +5,7 @@ from fs.osfs import OSFS
|
||||
from json import dumps
|
||||
|
||||
|
||||
def export_to_xml(modulestore, contentstore, course_location, root_dir, course_dir):
|
||||
def export_to_xml(modulestore, contentstore, course_location, root_dir, course_dir, draft_modulestore = None):
|
||||
|
||||
course = modulestore.get_item(course_location)
|
||||
|
||||
@@ -41,6 +41,24 @@ def export_to_xml(modulestore, contentstore, course_location, root_dir, course_d
|
||||
policy = {'course/' + course.location.name: course.metadata}
|
||||
course_policy.write(dumps(policy))
|
||||
|
||||
# export everything from the draft store, unfortunately this will create lots of duplicates
|
||||
if draft_modulestore is not None:
|
||||
draft_course = draft_modulestore.get_item(course_location)
|
||||
draft_course_dir = export_fs.makeopendir('drafts')
|
||||
xml = draft_course.export_to_xml(draft_course_dir)
|
||||
with draft_course_dir.open('course.xml', 'w') as course_xml:
|
||||
course_xml.write(xml)
|
||||
|
||||
'''
|
||||
draft_items = modulestore.get_items([None, None, None, 'vertical', None, 'draft'])
|
||||
logging.debug('draft_items = {0}'.format(draft_items))
|
||||
if len(draft_items) > 0:
|
||||
|
||||
for draft_item in draft_items:
|
||||
draft_item.export_to_xml(draft_items_dir)
|
||||
#with draft_items_dir.open(draft_item.location.name + '.xml', 'w'):
|
||||
'''
|
||||
|
||||
|
||||
def export_extra_content(export_fs, modulestore, course_location, category_type, dirname, file_suffix=''):
|
||||
query_loc = Location('i4x', course_location.org, course_location.course, category_type, None)
|
||||
|
||||
@@ -220,9 +220,15 @@ def import_from_xml(store, data_dir, course_dirs=None,
|
||||
# inherited metadata everywhere.
|
||||
store.update_metadata(module.location, dict(module.own_metadata))
|
||||
|
||||
# now import any 'draft' items
|
||||
import_course_draft(store, course_data_path, target_location_namespace)
|
||||
|
||||
return module_store, course_items
|
||||
|
||||
|
||||
def import_course_draft(store, course_data_path, target_location_namespace):
|
||||
pass
|
||||
|
||||
def remap_namespace(module, target_location_namespace):
|
||||
if target_location_namespace is None:
|
||||
return module
|
||||
|
||||
@@ -105,8 +105,7 @@ class XmlDescriptor(XModuleDescriptor):
|
||||
'name', 'slug')
|
||||
|
||||
metadata_to_strip = ('data_dir',
|
||||
# cdodge: @TODO: We need to figure out a way to export out 'tabs' and 'grading_policy' which is on the course
|
||||
'tabs', 'grading_policy', 'is_draft', 'published_by', 'published_date',
|
||||
'tabs', 'grading_policy', 'published_by', 'published_date',
|
||||
'discussion_blackouts', 'testcenter_info',
|
||||
# VS[compat] -- remove the below attrs once everything is in the CMS
|
||||
'course', 'org', 'url_name', 'filename')
|
||||
@@ -129,7 +128,8 @@ class XmlDescriptor(XModuleDescriptor):
|
||||
'hide_progress_tab': bool_map,
|
||||
'allow_anonymous': bool_map,
|
||||
'allow_anonymous_to_peers': bool_map,
|
||||
'weight': int_map
|
||||
'weight': int_map,
|
||||
'is_draft': bool_map
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user