Add command to get discussion_link for a course
This will be used to detect courses that are linking to Stack Exchange sites so we can handle them specially when generating data dumps.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
|
||||
from courseware.courses import get_course
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
args = "<course_id>"
|
||||
|
||||
def handle(self, *args, **options):
|
||||
if not args:
|
||||
raise CommandError("Course id not specified")
|
||||
if len(args) > 1:
|
||||
raise CommandError("Only one course id may be specifiied")
|
||||
course_id = args[0]
|
||||
|
||||
try:
|
||||
course = get_course(course_id)
|
||||
except ValueError:
|
||||
raise CommandError("Invalid course id: {}".format(course_id))
|
||||
|
||||
if course.discussion_link:
|
||||
self.stdout.write(course.discussion_link)
|
||||
Reference in New Issue
Block a user