Commit 858f3ae5 by Han Su Kim

Merge pull request #4075 from edx/han/regenerate_user

Transition to Oqaque Keys
parents a58149eb 8fdec439
"""Django management command to force certificate regeneration for one user""" """Django management command to force certificate regeneration for one user"""
from optparse import make_option from optparse import make_option
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from opaque_keys import InvalidKeyError
from certificates.queue import XQueueCertInterface from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from xmodule.course_module import CourseDescriptor from xmodule.course_module import CourseDescriptor
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from certificates.queue import XQueueCertInterface
class Command(BaseCommand): class Command(BaseCommand):
...@@ -48,9 +49,17 @@ class Command(BaseCommand): ...@@ -48,9 +49,17 @@ class Command(BaseCommand):
) )
def handle(self, *args, **options): def handle(self, *args, **options):
if options['course']:
# try to parse out the course from the serialized form
try:
course_id = CourseKey.from_string(options['course'])
except InvalidKeyError:
print("Course id {} could not be parsed as a CourseKey; falling back to SSCK.from_dep_str".format(options['course']))
course_id = SlashSeparatedCourseKey.from_deprecated_string(options['course'])
else:
raise CommandError("You must specify a course")
user = options['username'] user = options['username']
course_id = options['course']
if not (course_id and user): if not (course_id and user):
raise CommandError('both course id and student username are required') raise CommandError('both course id and student username are required')
......
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