Commit ff696a2f by Don Mitchell

Merge pull request #4440 from edx/bug/import

Bug/import
parents 1bd6c711 e897b461
...@@ -210,17 +210,15 @@ def import_handler(request, course_key_string): ...@@ -210,17 +210,15 @@ def import_handler(request, course_key_string):
status=415 status=415
) )
logging.debug('found course.xml at {0}'.format(dirpath)) dirpath = os.path.relpath(dirpath, data_root)
if dirpath != course_dir: logging.debug('found course.xml at {0}'.format(dirpath))
for fname in os.listdir(dirpath):
shutil.move(dirpath / fname, course_dir)
_module_store, course_items = import_from_xml( _module_store, course_items = import_from_xml(
modulestore(), modulestore(),
request.user.id, request.user.id,
settings.GITHUB_REPO_ROOT, settings.GITHUB_REPO_ROOT,
[course_subdir], [dirpath],
load_error_modules=False, load_error_modules=False,
static_content_store=contentstore(), static_content_store=contentstore(),
target_course_id=course_key, target_course_id=course_key,
......
...@@ -45,11 +45,13 @@ class ImportTestCase(CourseTestCase): ...@@ -45,11 +45,13 @@ class ImportTestCase(CourseTestCase):
# Create tar test files ----------------------------------------------- # Create tar test files -----------------------------------------------
# OK course: # OK course:
good_dir = tempfile.mkdtemp(dir=self.content_dir) good_dir = tempfile.mkdtemp(dir=self.content_dir)
os.makedirs(os.path.join(good_dir, "course")) # test course being deeper down than top of tar file
with open(os.path.join(good_dir, "course.xml"), "w+") as f: embedded_dir = os.path.join(good_dir, "grandparent", "parent")
os.makedirs(os.path.join(embedded_dir, "course"))
with open(os.path.join(embedded_dir, "course.xml"), "w+") as f:
f.write('<course url_name="2013_Spring" org="EDx" course="0.00x"/>') f.write('<course url_name="2013_Spring" org="EDx" course="0.00x"/>')
with open(os.path.join(good_dir, "course", "2013_Spring.xml"), "w+") as f: with open(os.path.join(embedded_dir, "course", "2013_Spring.xml"), "w+") as f:
f.write('<course></course>') f.write('<course></course>')
self.good_tar = os.path.join(self.content_dir, "good.tar.gz") self.good_tar = os.path.join(self.content_dir, "good.tar.gz")
......
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