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
55bfe46e
Commit
55bfe46e
authored
Aug 07, 2013
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
need to filter out non-own metadata. Also we need to clone draft content
parent
edc62ff6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
31 deletions
+38
-31
common/lib/xmodule/xmodule/modulestore/store_utilities.py
+38
-31
No files found.
common/lib/xmodule/xmodule/modulestore/store_utilities.py
View file @
55bfe46e
from
xmodule.contentstore.content
import
StaticContent
from
xmodule.contentstore.content
import
StaticContent
from
xmodule.modulestore
import
Location
from
xmodule.modulestore
import
Location
from
xmodule.modulestore.mongo
import
MongoModuleStore
from
xmodule.modulestore.mongo
import
MongoModuleStore
from
xmodule.modulestore.inheritance
import
own_metadata
import
logging
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
):
def
clone_course
(
modulestore
,
contentstore
,
source_location
,
dest_location
,
delete_original
=
False
):
# first check to see if the modulestore is Mongo backed
# first check to see if the modulestore is Mongo backed
if
not
isinstance
(
modulestore
,
MongoModuleStore
):
if
not
isinstance
(
modulestore
,
MongoModuleStore
):
...
@@ -37,38 +72,10 @@ def clone_course(modulestore, contentstore, source_location, dest_location, dele
...
@@ -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
# 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
])
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
:
modules
=
modulestore
.
get_items
([
source_location
.
tag
,
source_location
.
org
,
source_location
.
course
,
None
,
None
,
'draft'
])
original_loc
=
Location
(
module
.
location
)
_clone_modules
(
modulestore
,
modules
,
dest_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
)
# now iterate through all of the assets and clone them
# now iterate through all of the assets and clone them
# first the thumbnails
# first the thumbnails
...
...
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