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
666828f7
Commit
666828f7
authored
Jan 28, 2013
by
John Jarvis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Command for certificate whitelist
parent
7e033d02
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
11 deletions
+12
-11
lms/djangoapps/certificates/management/commands/cert_whitelist.py
+12
-11
No files found.
lms/djangoapps/certificates/management/commands/cert_whitelist.py
View file @
666828f7
from
django.core.management.base
import
BaseCommand
,
CommandError
import
os
from
optparse
import
make_option
from
student.models
import
UserProfile
from
certificates.models
import
CertificateWhitelist
from
django.contrib.auth.models
import
User
class
Command
(
BaseCommand
):
help
=
"""
...
...
@@ -16,12 +15,12 @@ class Command(BaseCommand):
$ ... cert_whitelist --add joe -c "MITx/6.002x/2012_Fall"
Remove a user from the whitelist for a course
$ ... cert_whitelist --del joe -c "MITx/6.002x/2012_Fall"
Print out who is whitelisted for a course
$ ... cert_whitelist -c "MITx/6.002x/2012_Fall"
$ ... cert_whitelist -c "MITx/6.002x/2012_Fall"
"""
...
...
@@ -37,7 +36,7 @@ class Command(BaseCommand):
dest
=
'del'
,
default
=
False
,
help
=
'user to remove from the certificate whitelist'
),
make_option
(
'-c'
,
'--course-id'
,
metavar
=
'COURSE_ID'
,
dest
=
'course_id'
,
...
...
@@ -50,7 +49,7 @@ class Command(BaseCommand):
if
not
course_id
:
raise
CommandError
(
"You must specify a course-id"
)
if
options
[
'add'
]
and
options
[
'del'
]:
raise
CommandError
(
"Either remove or add a user, not both"
)
raise
CommandError
(
"Either remove or add a user, not both"
)
if
options
[
'add'
]
or
options
[
'del'
]:
user_str
=
options
[
'add'
]
or
options
[
'del'
]
...
...
@@ -59,8 +58,9 @@ class Command(BaseCommand):
else
:
user
=
User
.
objects
.
get
(
username
=
user_str
)
cert_whitelist
,
created
=
CertificateWhitelist
.
objects
.
get_or_create
(
user
=
user
,
course_id
=
course_id
)
cert_whitelist
,
created
=
\
CertificateWhitelist
.
objects
.
get_or_create
(
user
=
user
,
course_id
=
course_id
)
if
options
[
'add'
]:
cert_whitelist
.
whitelist
=
True
elif
options
[
'del'
]:
...
...
@@ -68,6 +68,7 @@ class Command(BaseCommand):
cert_whitelist
.
save
()
whitelist
=
CertificateWhitelist
.
objects
.
all
()
print
"User whitelist for course {0}:
\n
{1}"
.
format
(
course_id
,
'
\n
'
.
join
([
"{0} {1} {2}"
.
format
(
u
.
user
.
username
,
u
.
user
.
email
,
u
.
whitelist
)
for
u
in
whitelist
]))
print
"User whitelist for course {0}:
\n
{1}"
.
format
(
course_id
,
'
\n
'
.
join
([
"{0} {1} {2}"
.
format
(
u
.
user
.
username
,
u
.
user
.
email
,
u
.
whitelist
)
for
u
in
whitelist
]))
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