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