Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
858f3ae5
Commit
858f3ae5
authored
Jun 13, 2014
by
Han Su Kim
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4075 from edx/han/regenerate_user
Transition to Oqaque Keys
parents
a58149eb
8fdec439
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
lms/djangoapps/certificates/management/commands/regenerate_user.py
+15
-6
No files found.
lms/djangoapps/certificates/management/commands/regenerate_user.py
View file @
858f3ae5
"""Django management command to force certificate regeneration for one user"""
from
optparse
import
make_option
from
django.contrib.auth.models
import
User
from
django.core.management.base
import
BaseCommand
,
CommandError
from
certificates.queue
import
XQueueCertInterface
from
opaque_keys
import
InvalidKeyError
from
opaque_keys.edx.keys
import
CourseKey
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
xmodule.course_module
import
CourseDescriptor
from
xmodule.modulestore.django
import
modulestore
from
certificates.queue
import
XQueueCertInterface
class
Command
(
BaseCommand
):
...
...
@@ -48,9 +49,17 @@ class Command(BaseCommand):
)
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'
]
course_id
=
options
[
'course'
]
if
not
(
course_id
and
user
):
raise
CommandError
(
'both course id and student username are required'
)
...
...
@@ -69,8 +78,8 @@ class Command(BaseCommand):
xq
=
XQueueCertInterface
()
if
options
[
'insecure'
]:
xq
.
use_https
=
False
ret
=
xq
.
regen_cert
(
student
,
course_id
,
course
=
course
,
forced_grade
=
options
[
'grade_value'
],
ret
=
xq
.
regen_cert
(
student
,
course_id
,
course
=
course
,
forced_grade
=
options
[
'grade_value'
],
template_file
=
options
[
'template_file'
])
print
'{0} - {1}'
.
format
(
student
,
ret
)
else
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment