Commit 3751bc05 by Calen Pennington

Merge pull request #870 from MITx/fix/cdodge/cas-bugs

Fix/cdodge/cas bugs
parents 64c3bbdc e2be559a
...@@ -570,6 +570,7 @@ def unpublish_unit(request): ...@@ -570,6 +570,7 @@ def unpublish_unit(request):
return HttpResponse() return HttpResponse()
@login_required @login_required
@expect_json @expect_json
def clone_item(request): def clone_item(request):
...@@ -581,10 +582,13 @@ def clone_item(request): ...@@ -581,10 +582,13 @@ def clone_item(request):
if not has_access(request.user, parent_location): if not has_access(request.user, parent_location):
raise PermissionDenied() raise PermissionDenied()
parent = modulestore().get_item(parent_location) # if we are creating a new section or subsection, then we don't want draft awareness
_modulestore = modulestore() if template.category not in ('sequential','chapter') else modulestore('direct')
parent = _modulestore.get_item(parent_location)
dest_location = parent_location._replace(category=template.category, name=uuid4().hex) dest_location = parent_location._replace(category=template.category, name=uuid4().hex)
new_item = modulestore().clone_item(template, dest_location) new_item = _modulestore.clone_item(template, dest_location)
# TODO: This needs to be deleted when we have proper storage for static content # TODO: This needs to be deleted when we have proper storage for static content
new_item.metadata['data_dir'] = parent.metadata['data_dir'] new_item.metadata['data_dir'] = parent.metadata['data_dir']
...@@ -593,7 +597,7 @@ def clone_item(request): ...@@ -593,7 +597,7 @@ def clone_item(request):
if display_name is not None: if display_name is not None:
new_item.metadata['display_name'] = display_name new_item.metadata['display_name'] = display_name
modulestore().update_metadata(new_item.location.url(), new_item.own_metadata) _modulestore.update_metadata(new_item.location.url(), new_item.own_metadata)
if parent_location.category not in ('vertical',): if parent_location.category not in ('vertical',):
parent_update_modulestore = modulestore('direct') parent_update_modulestore = modulestore('direct')
......
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