From 7a87179dc2fea66dd5e7d9e035dec945e12f3a50 Mon Sep 17 00:00:00 2001 From: Diana Huang Date: Thu, 15 May 2014 16:34:27 -0400 Subject: [PATCH] Update get_discussion_link command to use CourseKeys --- .../management/commands/get_discussion_link.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/django_comment_client/management/commands/get_discussion_link.py b/lms/djangoapps/django_comment_client/management/commands/get_discussion_link.py index 803fd3b4aa..7376429d76 100644 --- a/lms/djangoapps/django_comment_client/management/commands/get_discussion_link.py +++ b/lms/djangoapps/django_comment_client/management/commands/get_discussion_link.py @@ -1,4 +1,7 @@ from django.core.management.base import BaseCommand, CommandError +from opaque_keys import InvalidKeyError +from xmodule.modulestore.keys import CourseKey +from xmodule.modulestore.locations import SlashSeparatedCourseKey from courseware.courses import get_course @@ -14,8 +17,12 @@ class Command(BaseCommand): course_id = args[0] try: - course = get_course(course_id) - except ValueError: + course_key = CourseKey.from_string(course_id) + except InvalidKeyError: + course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id) + + course = get_course(course_key) + if not course: raise CommandError("Invalid course id: {}".format(course_id)) if course.discussion_link: