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
30184dbd
Commit
30184dbd
authored
May 21, 2014
by
Don Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Serial number commands deserialize course keys
parent
50d66be2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
10 deletions
+8
-10
lms/djangoapps/licenses/management/commands/generate_serial_numbers.py
+4
-5
lms/djangoapps/licenses/management/commands/import_serial_numbers.py
+4
-5
No files found.
lms/djangoapps/licenses/management/commands/generate_serial_numbers.py
View file @
30184dbd
...
...
@@ -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
)
...
...
lms/djangoapps/licenses/management/commands/import_serial_numbers.py
View file @
30184dbd
...
...
@@ -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
)
...
...
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