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
9981c867
Commit
9981c867
authored
Jan 20, 2016
by
Adam Palay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove old management commands
parent
4938601c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
0 additions
and
221 deletions
+0
-221
cms/djangoapps/contentstore/management/commands/check_course.py
+0
-65
common/djangoapps/student/management/commands/6002exportusers.py
+0
-53
common/djangoapps/student/management/commands/6002importusers.py
+0
-57
common/djangoapps/student/management/commands/emaillist.py
+0
-15
common/djangoapps/student/management/commands/userinfo.py
+0
-31
No files found.
cms/djangoapps/contentstore/management/commands/check_course.py
deleted
100644 → 0
View file @
4938601c
from
django.core.management.base
import
BaseCommand
,
CommandError
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.xml_importer
import
check_module_metadata_editability
from
opaque_keys.edx.keys
import
CourseKey
from
opaque_keys
import
InvalidKeyError
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
class
Command
(
BaseCommand
):
help
=
'''Enumerates through the course and find common errors'''
def
handle
(
self
,
*
args
,
**
options
):
if
len
(
args
)
!=
1
:
raise
CommandError
(
"check_course requires one argument: <course_id>"
)
try
:
course_key
=
CourseKey
.
from_string
(
args
[
0
])
except
InvalidKeyError
:
course_key
=
SlashSeparatedCourseKey
.
from_deprecated_string
(
args
[
0
])
store
=
modulestore
()
course
=
store
.
get_course
(
course_key
,
depth
=
3
)
err_cnt
=
0
def
_xlint_metadata
(
module
):
err_cnt
=
check_module_metadata_editability
(
module
)
for
child
in
module
.
get_children
():
err_cnt
=
err_cnt
+
_xlint_metadata
(
child
)
return
err_cnt
err_cnt
=
err_cnt
+
_xlint_metadata
(
course
)
# we've had a bug where the xml_attributes field can we rewritten as a string rather than a dict
def
_check_xml_attributes_field
(
module
):
err_cnt
=
0
if
hasattr
(
module
,
'xml_attributes'
)
and
isinstance
(
module
.
xml_attributes
,
basestring
):
print
'module = {0} has xml_attributes as a string. It should be a dict'
.
format
(
module
.
location
)
err_cnt
=
err_cnt
+
1
for
child
in
module
.
get_children
():
err_cnt
=
err_cnt
+
_check_xml_attributes_field
(
child
)
return
err_cnt
err_cnt
=
err_cnt
+
_check_xml_attributes_field
(
course
)
# check for dangling discussion items, this can cause errors in the forums
def
_get_discussion_items
(
module
):
discussion_items
=
[]
if
module
.
location
.
category
==
'discussion'
:
discussion_items
=
discussion_items
+
[
module
.
location
]
for
child
in
module
.
get_children
():
discussion_items
=
discussion_items
+
_get_discussion_items
(
child
)
return
discussion_items
discussion_items
=
_get_discussion_items
(
course
)
# now query all discussion items via get_items() and compare with the tree-traversal
queried_discussion_items
=
store
.
get_items
(
course_key
=
course_key
,
qualifiers
=
{
'category'
:
'discussion'
})
for
item
in
queried_discussion_items
:
if
item
.
location
not
in
discussion_items
:
print
'Found dangling discussion module = {0}'
.
format
(
item
.
location
)
common/djangoapps/student/management/commands/6002exportusers.py
deleted
100644 → 0
View file @
4938601c
##
## One-off script to export 6.002x users into the edX framework
##
## Could be modified to be general by:
## * Changing user_keys and up_keys to handle dates more cleanly
## * Providing a generic set of tables, rather than just users and user profiles
## * Handling certificates and grades
## * Handling merge/forks of UserProfile.meta
import
datetime
import
json
from
django.core.management.base
import
BaseCommand
from
django.contrib.auth.models
import
User
from
student.models
import
UserProfile
class
Command
(
BaseCommand
):
help
=
"""Exports all users and user profiles.
Caveat: Should be looked over before any run
for schema changes.
Current version grabs user_keys from
django.contrib.auth.models.User and up_keys
from student.userprofile."""
def
handle
(
self
,
*
args
,
**
options
):
users
=
list
(
User
.
objects
.
all
())
user_profiles
=
list
(
UserProfile
.
objects
.
all
())
user_profile_dict
=
dict
([(
up
.
user_id
,
up
)
for
up
in
user_profiles
])
user_tuples
=
[(
user_profile_dict
[
u
.
id
],
u
)
for
u
in
users
if
u
.
id
in
user_profile_dict
]
user_keys
=
[
'id'
,
'username'
,
'email'
,
'password'
,
'is_staff'
,
'is_active'
,
'is_superuser'
,
'last_login'
,
'date_joined'
,
'password'
]
up_keys
=
[
'language'
,
'location'
,
'meta'
,
'name'
,
'id'
,
'user_id'
]
def
extract_dict
(
keys
,
object
):
d
=
{}
for
key
in
keys
:
item
=
object
.
__getattribute__
(
key
)
if
type
(
item
)
==
datetime
.
datetime
:
item
=
item
.
isoformat
()
d
[
key
]
=
item
return
d
extracted
=
[{
'up'
:
extract_dict
(
up_keys
,
t
[
0
]),
'u'
:
extract_dict
(
user_keys
,
t
[
1
])}
for
t
in
user_tuples
]
fp
=
open
(
'transfer_users.txt'
,
'w'
)
json
.
dump
(
extracted
,
fp
)
fp
.
close
()
common/djangoapps/student/management/commands/6002importusers.py
deleted
100644 → 0
View file @
4938601c
##
## One-off script to import 6.002x users into the edX framework
## See export for more info
import
json
import
dateutil.parser
from
django.core.management.base
import
BaseCommand
from
django.contrib.auth.models
import
User
from
student.models
import
UserProfile
def
import_user
(
u
):
user_info
=
u
[
'u'
]
up_info
=
u
[
'up'
]
# HACK to handle dates
user_info
[
'last_login'
]
=
dateutil
.
parser
.
parse
(
user_info
[
'last_login'
])
user_info
[
'date_joined'
]
=
dateutil
.
parser
.
parse
(
user_info
[
'date_joined'
])
user_keys
=
[
'id'
,
'username'
,
'email'
,
'password'
,
'is_staff'
,
'is_active'
,
'is_superuser'
,
'last_login'
,
'date_joined'
,
'password'
]
up_keys
=
[
'language'
,
'location'
,
'meta'
,
'name'
,
'id'
,
'user_id'
]
u
=
User
()
for
key
in
user_keys
:
u
.
__setattr__
(
key
,
user_info
[
key
])
u
.
save
()
up
=
UserProfile
()
up
.
user
=
u
for
key
in
up_keys
:
up
.
__setattr__
(
key
,
up_info
[
key
])
up
.
save
()
class
Command
(
BaseCommand
):
help
=
"""Exports all users and user profiles.
Caveat: Should be looked over before any run
for schema changes.
Current version grabs user_keys from
django.contrib.auth.models.User and up_keys
from student.userprofile."""
def
handle
(
self
,
*
args
,
**
options
):
extracted
=
json
.
load
(
open
(
'transfer_users.txt'
))
n
=
0
for
u
in
extracted
:
import_user
(
u
)
if
n
%
100
==
0
:
print
n
n
=
n
+
1
common/djangoapps/student/management/commands/emaillist.py
deleted
100644 → 0
View file @
4938601c
from
django.core.management.base
import
BaseCommand
from
django.contrib.auth.models
import
User
class
Command
(
BaseCommand
):
help
=
'Extract an e-mail list of all active students.'
def
handle
(
self
,
*
args
,
**
options
):
#text = open(args[0]).read()
#subject = open(args[1]).read()
users
=
User
.
objects
.
all
()
for
user
in
users
:
if
user
.
is_active
:
print
user
.
email
common/djangoapps/student/management/commands/userinfo.py
deleted
100644 → 0
View file @
4938601c
from
django.core.management.base
import
BaseCommand
from
django.contrib.auth.models
import
User
import
json
from
student.models
import
UserProfile
class
Command
(
BaseCommand
):
help
=
"""Extract full user information into a JSON file.
Pass a single filename."""
def
handle
(
self
,
*
args
,
**
options
):
file_output
=
open
(
args
[
0
],
'w'
)
users
=
User
.
objects
.
all
()
data_list
=
[]
for
user
in
users
:
profile
=
UserProfile
.
objects
.
get
(
user
=
user
)
data
=
{
'username'
:
user
.
username
,
'email'
:
user
.
email
,
'is_active'
:
user
.
is_active
,
'joined'
:
user
.
date_joined
.
isoformat
(),
'name'
:
profile
.
name
,
'language'
:
profile
.
language
,
'location'
:
profile
.
location
,
}
data_list
.
append
(
data
)
json
.
dump
(
data_list
,
file_output
)
file_output
.
close
()
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