OLX export: Reverted url_name from a constant to course run

- New exported courses include course run information in:
  - `url_name` of root course node
  - file name of root node in course folder
  - root key name in policy.json
  - directory name inside policies folder

- when imported via management command, the OLX will overwrite an
available existing course with the same course key (i.e. same org,
course number and course run)
  - if there is no matching course, one will be created

- when imported via the studio web ui (or import API), the OLX will
replace the current course (no change in behavior)

- courses exported with this commit have been tested to import via
management command and studio web UI in hawthorn and ginkgo releases.
They should also work in prior releases, but have not been tested.
This commit is contained in:
Amir Qayyum Khan
2018-08-27 16:54:45 +05:00
parent b30e46a2e3
commit 0e2febbce2
5 changed files with 18 additions and 12 deletions

View File

@@ -487,7 +487,11 @@ class XmlParserMixin(object):
if self.export_to_file():
# Write the definition to a file
url_path = name_to_pathname(self.url_name)
filepath = self._format_filepath(self.category, url_path)
# if folder is course then create file with name {course_run}.xml
filepath = self._format_filepath(
self.category,
self.location.run if self.category == 'course' else url_path,
)
self.runtime.export_fs.makedirs(os.path.dirname(filepath), recreate=True)
with self.runtime.export_fs.open(filepath, 'wb') as fileobj:
ElementTree(xml_object).write(fileobj, pretty_print=True, encoding='utf-8')