From 281f194b2a117b738e7db8b0cc66cd63ff3b987c Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Fri, 12 Oct 2012 09:25:13 -0400 Subject: [PATCH] per feedback, change back 'draft-aware' modulestore to not delete the published copy. In delete_item in views.py do the logic to determine whether we should be using a 'draft-aware' modulestore or not, based on the category type --- cms/djangoapps/contentstore/views.py | 10 ++++++++-- common/lib/xmodule/xmodule/modulestore/draft.py | 5 +---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index 8911150fbb..7d27db51e2 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -470,10 +470,16 @@ def delete_item(request): item = modulestore().get_item(item_location) + _direct_delete_categories = ['course', 'chapter', 'sequential'] + + # @TODO: this probably leaves draft items dangling. + if delete_children: - _xmodule_recurse(item, lambda i: modulestore().delete_item(i.location)) + _xmodule_recurse(item, lambda i: modulestore('direct' if + i.location.category in _direct_delete_categories else 'direct').delete_item(i.location)) else: - modulestore().delete_item(item.location) + modulestore('direct' if + item.location.category in _direct_delete_categories else 'direct').delete_item(item.location) return HttpResponse() diff --git a/common/lib/xmodule/xmodule/modulestore/draft.py b/common/lib/xmodule/xmodule/modulestore/draft.py index 33ee9eaab2..5fbf05ed9b 100644 --- a/common/lib/xmodule/xmodule/modulestore/draft.py +++ b/common/lib/xmodule/xmodule/modulestore/draft.py @@ -157,11 +157,8 @@ class DraftModuleStore(ModuleStoreBase): location: Something that can be passed to Location """ + return super(DraftModuleStore, self).delete_item(as_draft(location)) - # cdodge: we should always delete both the draft and the original - super(DraftModuleStore, self).delete_item(as_draft(location)) - if (location.revision == None): # did caller request to delete the non-draft, if so be sure to do that - super(DraftModuleStore, self).delete_item(location) def get_parent_locations(self, location): '''Find all locations that are the parents of this location. Needed