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
f7d48319
Commit
f7d48319
authored
Aug 17, 2012
by
ichuang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update utility scripts for djang-1.4; will make them management cmds later
parent
a6c6d0f4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
10 deletions
+89
-10
utility-scripts/create_groups.py
+8
-5
utility-scripts/create_user.py
+7
-5
utility-scripts/manage_class_groups.py
+74
-0
No files found.
utility-scripts/create_groups.py
View file @
f7d48319
...
...
@@ -9,17 +9,20 @@ import os, sys, string, re
sys
.
path
.
append
(
os
.
path
.
abspath
(
'.'
))
os
.
environ
[
'DJANGO_SETTINGS_MODULE'
]
=
'lms.envs.dev'
try
:
from
lms.envs.dev
import
*
except
Exception
as
err
:
print
"Run this script from the top-level mitx directory (mitx_all/mitx), not a subdirectory."
sys
.
exit
(
-
1
)
#
try:
#
from lms.envs.dev import *
#
except Exception as err:
#
print "Run this script from the top-level mitx directory (mitx_all/mitx), not a subdirectory."
#
sys.exit(-1)
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
,
Group
from
path
import
path
from
lxml
import
etree
print
"configured="
,
settings
.
configured
print
settings
.
SETTINGS_MODULE
data_dir
=
settings
.
DATA_DIR
print
"data_dir =
%
s"
%
data_dir
...
...
utility-scripts/create_user.py
View file @
f7d48319
...
...
@@ -13,11 +13,13 @@ import readline
sys
.
path
.
append
(
os
.
path
.
abspath
(
'.'
))
os
.
environ
[
'DJANGO_SETTINGS_MODULE'
]
=
'lms.envs.dev'
try
:
from
lms.envs.dev
import
*
except
Exception
as
err
:
print
"Run this script from the top-level mitx directory (mitx_all/mitx), not a subdirectory."
sys
.
exit
(
-
1
)
#try:
# from lms.envs.dev import *
#except Exception as err:
# print "Run this script from the top-level mitx directory (mitx_all/mitx), not a subdirectory."
# sys.exit(-1)
sys
.
path
.
append
(
os
.
path
.
abspath
(
'common/djangoapps'
))
from
student.models
import
UserProfile
,
Registration
from
external_auth.models
import
ExternalAuthMap
...
...
utility-scripts/manage_class_groups.py
0 → 100644
View file @
f7d48319
#!/usr/bin/python
#
# File: manage_class_groups
#
# list and edit membership in class staff group
import
os
,
sys
,
string
,
re
import
datetime
from
getpass
import
getpass
import
json
import
readline
sys
.
path
.
append
(
os
.
path
.
abspath
(
'.'
))
os
.
environ
[
'DJANGO_SETTINGS_MODULE'
]
=
'lms.envs.dev'
#try:
# from lms.envs.dev import *
#except Exception as err:
# print "Run this script from the top-level mitx directory (mitx_all/mitx), not a subdirectory."
# sys.exit(-1)
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
,
Group
#-----------------------------------------------------------------------------
# get all staff groups
gset
=
Group
.
objects
.
all
()
print
"Groups:"
for
cnt
,
g
in
zip
(
range
(
len
(
gset
)),
gset
):
print
"
%
d.
%
s"
%
(
cnt
,
g
)
gnum
=
int
(
raw_input
(
'Choose group to manage (enter #): '
))
group
=
gset
[
gnum
]
#-----------------------------------------------------------------------------
# users in group
uall
=
User
.
objects
.
all
()
print
"----"
print
"List of All Users:
%
s"
%
[
str
(
x
.
username
)
for
x
in
uall
]
print
"----"
while
True
:
print
"Users in the group:"
uset
=
group
.
user_set
.
all
()
for
cnt
,
u
in
zip
(
range
(
len
(
uset
)),
uset
):
print
"
%
d.
%
s"
%
(
cnt
,
u
)
action
=
raw_input
(
'Choose user to delete (enter #) or enter usernames (comma delim) to add: '
)
m
=
re
.
match
(
'^[0-9]+$'
,
action
)
if
m
:
unum
=
int
(
action
)
u
=
uset
[
unum
]
print
"Deleting user
%
s"
%
u
u
.
groups
.
remove
(
group
)
else
:
for
uname
in
action
.
split
(
','
):
try
:
user
=
User
.
objects
.
get
(
username
=
action
)
except
Exception
as
err
:
print
"Error
%
s"
%
err
continue
print
"adding
%
s to group
%
s"
%
(
user
,
group
)
user
.
groups
.
add
(
group
)
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