Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
0c43e69c
Commit
0c43e69c
authored
12 years ago
by
John Jarvis
Browse files
Options
Downloads
Patches
Plain Diff
command for certificate restriction (embargoed countries)
parent
e9722b25
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/djangoapps/student/management/commands/cert_restriction.py
+15
-16
15 additions, 16 deletions
...jangoapps/student/management/commands/cert_restriction.py
with
15 additions
and
16 deletions
common/djangoapps/student/management/commands/cert_restriction.py
+
15
−
16
View file @
0c43e69c
...
...
@@ -9,15 +9,13 @@ class Command(BaseCommand):
help
=
"""
Sets or gets certificate restrictions for users
from embargoed countries.
from embargoed countries. (allow_certificate in
userprofile)
Import a list of students to restrict certificate download
by setting
"
allow_certificate
"
to True in userprofile:
CSV should be comma delimited with double quoted entries.
$ ... cert_restriction --import path/to/userlist.csv
CSV should be comma delimited with double quoted entries.
Export a list of students who have
"
allow_certificate
"
in
userprofile set to True
...
...
@@ -50,7 +48,6 @@ class Command(BaseCommand):
)
def
handle
(
self
,
*
args
,
**
options
):
if
options
[
'
output
'
]:
if
os
.
path
.
exists
(
options
[
'
output
'
]):
...
...
@@ -63,33 +60,34 @@ class Command(BaseCommand):
csvwriter
=
csv
.
writer
(
csvfile
,
delimiter
=
'
,
'
,
quotechar
=
'"'
,
quoting
=
csv
.
QUOTE_MINIMAL
)
for
user
in
disabled_users
:
csvwriter
.
writerow
([
user
.
username
])
csvwriter
.
writerow
([
user
.
user
.
username
])
elif
options
[
'
i
npu
t
'
]:
elif
options
[
'
i
mpor
t
'
]:
if
not
os
.
path
.
exists
(
options
[
'
i
npu
t
'
]):
if
not
os
.
path
.
exists
(
options
[
'
i
mpor
t
'
]):
raise
CommandError
(
"
File {0} does not exist
"
.
format
(
options
[
'
i
npu
t
'
]))
options
[
'
i
mpor
t
'
]))
print
"
Importing students from {0}
"
.
format
(
options
[
'
i
npu
t
'
])
print
"
Importing students from {0}
"
.
format
(
options
[
'
i
mpor
t
'
])
students
=
None
with
open
(
options
[
'
i
npu
t
'
])
as
csvfile
:
with
open
(
options
[
'
i
mpor
t
'
])
as
csvfile
:
student_list
=
csv
.
reader
(
csvfile
,
delimiter
=
'
,
'
,
quotechar
=
'"'
)
students
=
[
student
[
0
]
for
student
in
student_list
]
if
not
students
:
raise
CommandError
(
"
Unable to read student data from {0}
"
.
format
(
options
[
'
i
npu
t
'
]))
UserProfile
.
objects
.
filter
(
username__in
=
students
).
update
(
options
[
'
i
mpor
t
'
]))
UserProfile
.
objects
.
filter
(
user__
username__in
=
students
).
update
(
allow_certificate
=
False
)
elif
options
[
'
enable
'
]:
print
"
Enabling {0} for certificate download
"
.
format
(
options
[
'
enable
'
])
cert_allow
=
UserProfile
.
objects
.
get
(
user
=
options
[
'
enable
'
])
cert_allow
=
UserProfile
.
objects
.
get
(
user__username
=
options
[
'
enable
'
])
cert_allow
.
allow_certificate
=
True
cert_allow
.
save
()
...
...
@@ -97,6 +95,7 @@ class Command(BaseCommand):
print
"
Disabling {0} for certificate download
"
.
format
(
options
[
'
disable
'
])
cert_allow
=
UserProfile
.
objects
.
get
(
user
=
options
[
'
disable
'
])
cert_allow
=
UserProfile
.
objects
.
get
(
user__username
=
options
[
'
disable
'
])
cert_allow
.
allow_certificate
=
False
cert_allow
.
save
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment