delete_course command with course keys containing unicode chars

This commit is contained in:
noraiz-anwar
2017-10-12 17:27:42 +05:00
parent a9d68c32c0
commit 8bc7ae1466

View File

@@ -32,7 +32,10 @@ class Command(BaseCommand):
help = 'Delete a MongoDB backed course' help = 'Delete a MongoDB backed course'
def add_arguments(self, parser): def add_arguments(self, parser):
parser.add_argument('course_key', help='ID of the course to delete.') parser.add_argument(
'course_key',
help='ID of the course to delete.',
)
parser.add_argument( parser.add_argument(
'--keep-instructors', '--keep-instructors',
@@ -50,7 +53,9 @@ class Command(BaseCommand):
def handle(self, *args, **options): def handle(self, *args, **options):
try: try:
course_key = CourseKey.from_string(options['course_key']) # a course key may have unicode chars in it
course_key = unicode(options['course_key'], 'utf8')
course_key = CourseKey.from_string(course_key)
except InvalidKeyError: except InvalidKeyError:
raise CommandError('Invalid course_key: {}'.format(options['course_key'])) raise CommandError('Invalid course_key: {}'.format(options['course_key']))