Commit 8ccd72c8 by Mathew Peterson

Merge pull request #4158 from edx/mathewpeterson/course_import_fix

Useless code path in import_from_xml causing errors removed
parents 7ff3f08f 3a351210
...@@ -48,7 +48,7 @@ class Command(BaseCommand): ...@@ -48,7 +48,7 @@ class Command(BaseCommand):
mstore, data_dir, course_dirs, load_error_modules=False, mstore, data_dir, course_dirs, load_error_modules=False,
static_content_store=contentstore(), verbose=True, static_content_store=contentstore(), verbose=True,
do_import_static=do_import_static, do_import_static=do_import_static,
create_new_course=True, create_new_course_if_not_present=True,
) )
for course in course_items: for course in course_items:
......
...@@ -111,7 +111,7 @@ def import_from_xml( ...@@ -111,7 +111,7 @@ def import_from_xml(
default_class='xmodule.raw_module.RawDescriptor', default_class='xmodule.raw_module.RawDescriptor',
load_error_modules=True, static_content_store=None, load_error_modules=True, static_content_store=None,
target_course_id=None, verbose=False, draft_store=None, target_course_id=None, verbose=False, draft_store=None,
do_import_static=True, create_new_course=False): do_import_static=True, create_new_course_if_not_present=False):
""" """
Import the specified xml data_dir into the "store" modulestore, Import the specified xml data_dir into the "store" modulestore,
using org and course as the location org and course. using org and course as the location org and course.
...@@ -133,8 +133,8 @@ def import_from_xml( ...@@ -133,8 +133,8 @@ def import_from_xml(
time the course is loaded. Static content for some courses may also be time the course is loaded. Static content for some courses may also be
served directly by nginx, instead of going through django. served directly by nginx, instead of going through django.
: create_new_course: : create_new_course_if_not_present:
If True, then courses whose ids already exist in the store are not imported. If True, then a new course is created if it doesn't already exist.
The check for existing courses is case-insensitive. The check for existing courses is case-insensitive.
""" """
...@@ -165,24 +165,17 @@ def import_from_xml( ...@@ -165,24 +165,17 @@ def import_from_xml(
else: else:
dest_course_id = course_key dest_course_id = course_key
if create_new_course: # Creates a new course if it doesn't already exist
# this tests if exactly this course (ignoring case) exists; so, it checks the run if create_new_course_if_not_present and not store.has_course(dest_course_id, ignore_case=True):
if store.has_course(dest_course_id, ignore_case=True): try:
log.debug( store.create_course(dest_course_id.org, dest_course_id.offering)
"Skipping import of course with id, {0}," except InvalidLocationError:
"since it collides with an existing one".format(dest_course_id) # course w/ same org and course exists
) log.debug(
continue "Skipping import of course with id, {0},"
else: "since it collides with an existing one".format(dest_course_id)
try: )
store.create_course(dest_course_id.org, dest_course_id.offering) continue
except InvalidLocationError:
# course w/ same org and course exists and store is old mongo
log.debug(
"Skipping import of course with id, {0},"
"since it collides with an existing one".format(dest_course_id)
)
continue
try: try:
# turn off all write signalling while importing as this # turn off all write signalling while importing as this
......
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