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
bcc22682
Commit
bcc22682
authored
Jul 03, 2013
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add code to actually go through and delete the draft modules
parent
b3723b1a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
6 deletions
+24
-6
common/lib/xmodule/xmodule/modulestore/store_utilities.py
+24
-6
No files found.
common/lib/xmodule/xmodule/modulestore/store_utilities.py
View file @
bcc22682
...
...
@@ -102,7 +102,27 @@ def clone_course(modulestore, contentstore, source_location, dest_location, dele
return
True
def
_delete_modules_except_course
(
modulestore
,
modules
,
source_location
,
commit
):
"""
This helper method will just enumerate through a list of modules and delete them, except for the
top-level course module
"""
for
module
in
modules
:
if
module
.
category
!=
'course'
:
print
"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
:
raise
Exception
(
'Module {0} is not in same namespace as {1}. This should not happen! Aborting...'
.
format
(
module
.
location
,
source_location
))
modulestore
.
delete_item
(
module
.
location
)
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
courseware store. BE VERY CAREFUL, this is not reversable.
"""
# first check to see if the modulestore is Mongo backed
if
not
isinstance
(
modulestore
,
MongoModuleStore
):
raise
Exception
(
"Expected a MongoModuleStore in the runtime. Aborting...."
)
...
...
@@ -131,12 +151,11 @@ def delete_course(modulestore, contentstore, source_location, commit=False):
# then delete all course modules
modules
=
modulestore
.
get_items
([
source_location
.
tag
,
source_location
.
org
,
source_location
.
course
,
None
,
None
,
None
])
_delete_modules_except_course
(
modulestore
,
modules
,
source_location
,
commit
)
for
module
in
modules
:
if
module
.
category
!=
'course'
:
# save deleting the course module for last
print
"Deleting {0}..."
.
format
(
module
.
location
)
if
commit
:
modulestore
.
delete_item
(
module
.
location
)
# then delete all draft course modules
modules
=
modulestore
.
get_items
([
source_location
.
tag
,
source_location
.
org
,
source_location
.
course
,
None
,
None
,
'draft'
])
_delete_modules_except_course
(
modulestore
,
modules
,
source_location
,
commit
)
# finally delete the top-level course module itself
print
"Deleting {0}..."
.
format
(
source_location
)
...
...
@@ -144,4 +163,3 @@ def delete_course(modulestore, contentstore, source_location, commit=False):
modulestore
.
delete_item
(
source_location
)
return
True
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