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
9f075073
Commit
9f075073
authored
Aug 02, 2013
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add same optimizations to the clone course command
parent
f57b02c1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
6 deletions
+21
-6
cms/djangoapps/contentstore/management/commands/clone.py
+21
-6
No files found.
cms/djangoapps/contentstore/management/commands/clone.py
View file @
9f075073
...
...
@@ -12,7 +12,14 @@ from auth.authz import _copy_course_group
#
# To run from command line: rake cms:clone SOURCE_LOC=MITx/111/Foo1 DEST_LOC=MITx/135/Foo3
#
from
request_cache.middleware
import
RequestCache
from
django.core.cache
import
get_cache
#
# To run from command line: rake cms:delete_course LOC=MITx/111/Foo1
#
CACHE
=
get_cache
(
'mongo_metadata_inheritance'
)
class
Command
(
BaseCommand
):
"""Clone a MongoDB-backed course to another location"""
...
...
@@ -21,19 +28,27 @@ class Command(BaseCommand):
def
handle
(
self
,
*
args
,
**
options
):
"Execute the command"
if
len
(
args
)
!=
2
:
raise
CommandError
(
"clone requires two arguments: <source-
location> <dest-location
>"
)
raise
CommandError
(
"clone requires two arguments: <source-
course_id> <dest-course_id
>"
)
source_
location_str
=
args
[
0
]
dest_
location_str
=
args
[
1
]
source_
course_id
=
args
[
0
]
dest_
course_id
=
args
[
1
]
mstore
=
modulestore
(
'direct'
)
cstore
=
contentstore
()
print
(
"Cloning course {0} to {1}"
.
format
(
source_location_str
,
dest_location_str
))
mstore
.
metadata_inheritance_cache_subsystem
=
CACHE
mstore
.
request_cache
=
RequestCache
.
get_request_cache
()
org
,
course_num
,
run
=
dest_course_id
.
split
(
"/"
)
mstore
.
ignore_write_events_on_courses
.
append
(
'{0}/{1}'
.
format
(
org
,
course_num
))
source_location
=
CourseDescriptor
.
id_to_location
(
source_location_str
)
dest_location
=
CourseDescriptor
.
id_to_location
(
dest_location_str
)
print
(
"Cloning course {0} to {1}"
.
format
(
source_course_id
,
dest_course_id
))
source_location
=
CourseDescriptor
.
id_to_location
(
source_course_id
)
dest_location
=
CourseDescriptor
.
id_to_location
(
dest_course_id
)
if
clone_course
(
mstore
,
cstore
,
source_location
,
dest_location
):
# be sure to recompute metadata inheritance after all those updates
mstore
.
refresh_cached_metadata_inheritance_tree
(
dest_location
)
print
(
"copying User permissions..."
)
_copy_course_group
(
source_location
,
dest_location
)
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