Commit 2e64bc33 by Chris Dodge

make sure delete_item always uses the draft store

parent ead18f9f
......@@ -615,9 +615,11 @@ def delete_item(request):
delete_children = request.POST.get('delete_children', False)
delete_all_versions = request.POST.get('delete_all_versions', False)
item = modulestore().get_item(item_location)
logging.debug('delete_all_versions = {0}'.format(delete_all_versions))
store = get_modulestore(item_loc)
store = modulestore()
item = store.get_item(item_location)
# @TODO: this probably leaves draft items dangling. My preferance would be for the semantic to be
# if item.location.revision=None, then delete both draft and published version
......
......@@ -15,6 +15,12 @@ def as_draft(location):
"""
return Location(location)._replace(revision=DRAFT)
def as_published(location):
"""
Returns the Location that is the published version for `location`
"""
return Location(location)._replace(revision=None)
def wrap_draft(item):
"""
......@@ -169,7 +175,7 @@ class DraftModuleStore(ModuleStoreBase):
"""
super(DraftModuleStore, self).delete_item(as_draft(location))
if delete_all_versions:
super(DraftModuleStore, self).delete_item(location)
super(DraftModuleStore, self).delete_item(as_published(location))
return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment