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
e92799bb
Commit
e92799bb
authored
Jul 03, 2013
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
switch from prints to logging.debug. Also refactor some duplicate code
parent
b18fb97e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
13 deletions
+17
-13
common/lib/xmodule/xmodule/modulestore/store_utilities.py
+17
-13
No files found.
common/lib/xmodule/xmodule/modulestore/store_utilities.py
View file @
e92799bb
...
...
@@ -2,6 +2,8 @@ from xmodule.contentstore.content import StaticContent
from
xmodule.modulestore
import
Location
from
xmodule.modulestore.mongo
import
MongoModuleStore
import
logging
def
clone_course
(
modulestore
,
contentstore
,
source_location
,
dest_location
,
delete_original
=
False
):
# first check to see if the modulestore is Mongo backed
...
...
@@ -109,7 +111,7 @@ def _delete_modules_except_course(modulestore, modules, source_location, commit)
"""
for
module
in
modules
:
if
module
.
category
!=
'course'
:
print
"Deleting {0}..."
.
format
(
module
.
location
)
logging
.
debug
(
"Deleting {0}..."
.
format
(
module
.
location
)
)
if
commit
:
# sanity check. Make sure we're not deleting a module in the incorrect course
if
module
.
location
.
org
!=
source_location
.
org
or
module
.
location
.
course
!=
source_location
.
course
:
...
...
@@ -117,6 +119,18 @@ def _delete_modules_except_course(modulestore, modules, source_location, commit)
modulestore
.
delete_item
(
module
.
location
)
def
_delete_assets
(
contentstore
,
assets
,
commit
):
"""
This helper method will enumerate through a list of assets and delete them
"""
for
asset
in
assets
:
asset_loc
=
Location
(
asset
[
"_id"
])
id
=
StaticContent
.
get_id_from_location
(
asset_loc
)
logging
.
debug
(
"Deleting {0}..."
.
format
(
id
))
if
commit
:
contentstore
.
delete
(
id
)
def
delete_course
(
modulestore
,
contentstore
,
source_location
,
commit
=
False
):
"""
This method will actually do the work to delete all content in a course in a MongoDB backed
...
...
@@ -133,21 +147,11 @@ def delete_course(modulestore, contentstore, source_location, commit=False):
# first delete all of the thumbnails
thumbs
=
contentstore
.
get_all_content_thumbnails_for_course
(
source_location
)
for
thumb
in
thumbs
:
thumb_loc
=
Location
(
thumb
[
"_id"
])
id
=
StaticContent
.
get_id_from_location
(
thumb_loc
)
print
"Deleting {0}..."
.
format
(
id
)
if
commit
:
contentstore
.
delete
(
id
)
_delete_assets
(
contentstore
,
thumbs
,
commit
)
# then delete all of the assets
assets
=
contentstore
.
get_all_content_for_course
(
source_location
)
for
asset
in
assets
:
asset_loc
=
Location
(
asset
[
"_id"
])
id
=
StaticContent
.
get_id_from_location
(
asset_loc
)
print
"Deleting {0}..."
.
format
(
id
)
if
commit
:
contentstore
.
delete
(
id
)
_delete_assets
(
contentstore
,
assets
,
commit
)
# then delete all course modules
modules
=
modulestore
.
get_items
([
source_location
.
tag
,
source_location
.
org
,
source_location
.
course
,
None
,
None
,
None
])
...
...
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