diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index 3a1ac1ebd1..a22d78900f 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -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 diff --git a/common/lib/xmodule/xmodule/modulestore/draft.py b/common/lib/xmodule/xmodule/modulestore/draft.py index a1372b25f0..d7300e1730 100644 --- a/common/lib/xmodule/xmodule/modulestore/draft.py +++ b/common/lib/xmodule/xmodule/modulestore/draft.py @@ -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