From 7c3d5d58b7cbc316041a35e8e473a31abf368591 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Tue, 9 Oct 2012 11:21:49 -0400 Subject: [PATCH] Fix up how parent locations interact w/ draft mode when creating new units --- cms/djangoapps/contentstore/views.py | 7 ++++++- common/lib/xmodule/xmodule/modulestore/draft.py | 10 +++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index d92190f645..ba362ec91a 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -571,7 +571,12 @@ def clone_item(request): new_item.metadata['display_name'] = display_name modulestore().update_metadata(new_item.location.url(), new_item.own_metadata) - modulestore().update_children(parent_location, parent.definition.get('children', []) + [new_item.location.url()]) + + if parent_location.category not in ('vertical',): + parent_update_modulestore = modulestore('direct') + else: + parent_update_modulestore = modulestore() + parent_update_modulestore.update_children(parent_location, parent.definition.get('children', []) + [new_item.location.url()]) return HttpResponse(json.dumps({'id': dest_location.url()})) diff --git a/common/lib/xmodule/xmodule/modulestore/draft.py b/common/lib/xmodule/xmodule/modulestore/draft.py index 9c58b12e82..78600f1ba0 100644 --- a/common/lib/xmodule/xmodule/modulestore/draft.py +++ b/common/lib/xmodule/xmodule/modulestore/draft.py @@ -100,7 +100,7 @@ class DraftModuleStore(ModuleStoreBase): Clone a new item that is a copy of the item at the location `source` and writes it to `location` """ - return super(DraftModuleStore, self).clone_item(source, as_draft(location)) + return wrap_draft(super(DraftModuleStore, self).clone_item(source, as_draft(location))) def update_item(self, location, data): """ @@ -159,6 +159,14 @@ class DraftModuleStore(ModuleStoreBase): """ return super(DraftModuleStore, self).delete_item(as_draft(location)) + def get_parent_locations(self, location): + '''Find all locations that are the parents of this location. Needed + for path_to_location(). + + returns an iterable of things that can be passed to Location. + ''' + return super(DraftModuleStore, self).get_parent_locations(location) + def publish(self, location, published_by_id): """ Save a current draft to the underlying modulestore