Serial number commands deserialize course keys
This commit is contained in:
@@ -6,6 +6,7 @@ from django.core.management.base import BaseCommand, CommandError
|
||||
from xmodule.modulestore.django import modulestore
|
||||
|
||||
from licenses.models import CourseSoftware, UserLicense
|
||||
from xmodule.modulestore.locations import SlashSeparatedCourseKey
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
@@ -36,10 +37,8 @@ class Command(BaseCommand):
|
||||
raise CommandError("Incorrect number of arguments")
|
||||
|
||||
course_id = args[0]
|
||||
courses = modulestore().get_courses()
|
||||
known_course_ids = set(c.id for c in courses)
|
||||
|
||||
if course_id not in known_course_ids:
|
||||
course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
|
||||
if not modulestore().has_course(course_key):
|
||||
raise CommandError("Unknown course_id")
|
||||
|
||||
software_name = escape(args[1].lower())
|
||||
@@ -49,7 +48,7 @@ class Command(BaseCommand):
|
||||
except ValueError:
|
||||
raise CommandError("Invalid <count> argument.")
|
||||
|
||||
return course_id, software_name, count
|
||||
return course_key, software_name, count
|
||||
|
||||
def _generate_serials(self, software, count):
|
||||
print "Generating {0} serials".format(count)
|
||||
|
||||
@@ -6,6 +6,7 @@ from django.core.management.base import BaseCommand, CommandError
|
||||
from xmodule.modulestore.django import modulestore
|
||||
|
||||
from licenses.models import CourseSoftware, UserLicense
|
||||
from xmodule.modulestore.locations import SlashSeparatedCourseKey
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
@@ -36,10 +37,8 @@ class Command(BaseCommand):
|
||||
raise CommandError("Incorrect number of arguments")
|
||||
|
||||
course_id = args[0]
|
||||
courses = modulestore().get_courses()
|
||||
known_course_ids = set(c.id for c in courses)
|
||||
|
||||
if course_id not in known_course_ids:
|
||||
course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
|
||||
if not modulestore().has_course(course_key):
|
||||
raise CommandError("Unknown course_id")
|
||||
|
||||
software_name = escape(args[1].lower())
|
||||
@@ -48,7 +47,7 @@ class Command(BaseCommand):
|
||||
if not os.path.exists(filename):
|
||||
raise CommandError("Cannot find filename {0}".format(filename))
|
||||
|
||||
return course_id, software_name, filename
|
||||
return course_key, software_name, filename
|
||||
|
||||
def _import_serials(self, software, filename):
|
||||
print "Importing serial numbers for {0}.".format(software)
|
||||
|
||||
Reference in New Issue
Block a user