Commit 12ae70b0 by Diana Huang

Merge pull request #3753 from edx/diana/update-forums-cmd

Update get_discussion_link command to use CourseKeys
parents f3fb82f8 7a87179d
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:
......
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