Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
55bfe46e
Commit
55bfe46e
authored
11 years ago
by
Chris Dodge
Browse files
Options
Downloads
Patches
Plain Diff
need to filter out non-own metadata. Also we need to clone draft content
parent
edc62ff6
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/lib/xmodule/xmodule/modulestore/store_utilities.py
+38
-31
38 additions, 31 deletions
common/lib/xmodule/xmodule/modulestore/store_utilities.py
with
38 additions
and
31 deletions
common/lib/xmodule/xmodule/modulestore/store_utilities.py
+
38
−
31
View file @
55bfe46e
from
xmodule.contentstore.content
import
StaticContent
from
xmodule.modulestore
import
Location
from
xmodule.modulestore.mongo
import
MongoModuleStore
from
xmodule.modulestore.inheritance
import
own_metadata
import
logging
def
_clone_modules
(
modulestore
,
modules
,
dest_location
):
for
module
in
modules
:
original_loc
=
Location
(
module
.
location
)
if
original_loc
.
category
!=
'
course
'
:
module
.
location
=
module
.
location
.
_replace
(
tag
=
dest_location
.
tag
,
org
=
dest_location
.
org
,
course
=
dest_location
.
course
)
else
:
# on the course module we also have to update the module name
module
.
location
=
module
.
location
.
_replace
(
tag
=
dest_location
.
tag
,
org
=
dest_location
.
org
,
course
=
dest_location
.
course
,
name
=
dest_location
.
name
)
print
"
Cloning module {0} to {1}....
"
.
format
(
original_loc
,
module
.
location
)
modulestore
.
update_item
(
module
.
location
,
module
.
_model_data
.
_kvs
.
_data
)
# repoint children
if
module
.
has_children
:
new_children
=
[]
for
child_loc_url
in
module
.
children
:
child_loc
=
Location
(
child_loc_url
)
child_loc
=
child_loc
.
_replace
(
tag
=
dest_location
.
tag
,
org
=
dest_location
.
org
,
course
=
dest_location
.
course
)
new_children
.
append
(
child_loc
.
url
())
modulestore
.
update_children
(
module
.
location
,
new_children
)
# save metadata
modulestore
.
update_metadata
(
module
.
location
,
own_metadata
(
module
))
def
clone_course
(
modulestore
,
contentstore
,
source_location
,
dest_location
,
delete_original
=
False
):
# first check to see if the modulestore is Mongo backed
if
not
isinstance
(
modulestore
,
MongoModuleStore
):
...
...
@@ -37,38 +72,10 @@ def clone_course(modulestore, contentstore, source_location, dest_location, dele
# Get all modules under this namespace which is (tag, org, course) tuple
modules
=
modulestore
.
get_items
([
source_location
.
tag
,
source_location
.
org
,
source_location
.
course
,
None
,
None
,
None
])
_clone_modules
(
modulestore
,
modules
,
dest_location
)
for
module
in
modules
:
original_loc
=
Location
(
module
.
location
)
if
original_loc
.
category
!=
'
course
'
:
module
.
location
=
module
.
location
.
_replace
(
tag
=
dest_location
.
tag
,
org
=
dest_location
.
org
,
course
=
dest_location
.
course
)
else
:
# on the course module we also have to update the module name
module
.
location
=
module
.
location
.
_replace
(
tag
=
dest_location
.
tag
,
org
=
dest_location
.
org
,
course
=
dest_location
.
course
,
name
=
dest_location
.
name
)
print
"
Cloning module {0} to {1}....
"
.
format
(
original_loc
,
module
.
location
)
modulestore
.
update_item
(
module
.
location
,
module
.
_model_data
.
_kvs
.
_data
)
# repoint children
if
module
.
has_children
:
new_children
=
[]
for
child_loc_url
in
module
.
children
:
child_loc
=
Location
(
child_loc_url
)
child_loc
=
child_loc
.
_replace
(
tag
=
dest_location
.
tag
,
org
=
dest_location
.
org
,
course
=
dest_location
.
course
)
new_children
.
append
(
child_loc
.
url
())
modulestore
.
update_children
(
module
.
location
,
new_children
)
# save metadata
modulestore
.
update_metadata
(
module
.
location
,
module
.
_model_data
.
_kvs
.
_metadata
)
modules
=
modulestore
.
get_items
([
source_location
.
tag
,
source_location
.
org
,
source_location
.
course
,
None
,
None
,
'
draft
'
])
_clone_modules
(
modulestore
,
modules
,
dest_location
)
# now iterate through all of the assets and clone them
# first the thumbnails
...
...
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