Commit 55011470 by chrisndodge

Merge pull request #974 from MITx/feature/cale/cas-dont-delete-subsection-children

Only update data in modules that have been set when passing into save_it...
parents 4bf5f970 bd1233d3
...@@ -577,11 +577,11 @@ def save_item(request): ...@@ -577,11 +577,11 @@ def save_item(request):
store = _modulestore(Location(item_location)); store = _modulestore(Location(item_location));
if request.POST['data'] is not None: if request.POST.get('data') is not None:
data = request.POST['data'] data = request.POST['data']
store.update_item(item_location, data) store.update_item(item_location, data)
if request.POST['children'] is not None: if request.POST.get('children') is not None:
children = request.POST['children'] children = request.POST['children']
store.update_children(item_location, children) store.update_children(item_location, children)
...@@ -590,7 +590,7 @@ def save_item(request): ...@@ -590,7 +590,7 @@ def save_item(request):
# NOTE, that the postback is not the complete metadata, as there's system metadata which is # NOTE, that the postback is not the complete metadata, as there's system metadata which is
# not presented to the end-user for editing. So let's fetch the original and # not presented to the end-user for editing. So let's fetch the original and
# 'apply' the submitted metadata, so we don't end up deleting system metadata # 'apply' the submitted metadata, so we don't end up deleting system metadata
if request.POST['metadata'] is not None: if request.POST.get('metadata') is not None:
posted_metadata = request.POST['metadata'] posted_metadata = request.POST['metadata']
# fetch original # fetch original
existing_item = modulestore().get_item(item_location) existing_item = modulestore().get_item(item_location)
......
class CMS.Models.Module extends Backbone.Model class CMS.Models.Module extends Backbone.Model
url: '/save_item' url: '/save_item'
defaults:
data: null
children: null
metadata: null
...@@ -218,7 +218,7 @@ function onUnitReordered() { ...@@ -218,7 +218,7 @@ function onUnitReordered() {
type: "POST", type: "POST",
dataType: "json", dataType: "json",
contentType: "application/json", contentType: "application/json",
data:JSON.stringify({ 'id' : subsection_id, 'metadata' : null, 'data': null, 'children' : children}) data:JSON.stringify({ 'id' : subsection_id, 'children' : children})
}); });
} }
...@@ -234,7 +234,7 @@ function onSubsectionReordered() { ...@@ -234,7 +234,7 @@ function onSubsectionReordered() {
type: "POST", type: "POST",
dataType: "json", dataType: "json",
contentType: "application/json", contentType: "application/json",
data:JSON.stringify({ 'id' : section_id, 'metadata' : null, 'data': null, 'children' : children}) data:JSON.stringify({ 'id' : section_id, 'children' : children})
}); });
} }
...@@ -250,7 +250,7 @@ function onSectionReordered() { ...@@ -250,7 +250,7 @@ function onSectionReordered() {
type: "POST", type: "POST",
dataType: "json", dataType: "json",
contentType: "application/json", contentType: "application/json",
data:JSON.stringify({ 'id' : course_id, 'metadata' : null, 'data': null, 'children' : children}) data:JSON.stringify({ 'id' : course_id, 'children' : children})
}); });
} }
...@@ -360,15 +360,12 @@ function saveSubsection() { ...@@ -360,15 +360,12 @@ function saveSubsection() {
metadata['start'] = getEdxTimeFromDateTimeInputs('start_date', 'start_time'); metadata['start'] = getEdxTimeFromDateTimeInputs('start_date', 'start_time');
metadata['due'] = getEdxTimeFromDateTimeInputs('due_date', 'due_time', 'MMMM dd HH:mm'); metadata['due'] = getEdxTimeFromDateTimeInputs('due_date', 'due_time', 'MMMM dd HH:mm');
// reordering is done through immediate callbacks when the resorting has completed in the UI
children =[];
$.ajax({ $.ajax({
url: "/save_item", url: "/save_item",
type: "POST", type: "POST",
dataType: "json", dataType: "json",
contentType: "application/json", contentType: "application/json",
data:JSON.stringify({ 'id' : id, 'metadata' : metadata, 'data': null, 'children' : children}), data:JSON.stringify({ 'id' : id, 'metadata' : metadata}),
success: function() { success: function() {
$spinner.delay(500).fadeOut(150); $spinner.delay(500).fadeOut(150);
}, },
...@@ -745,7 +742,7 @@ function saveEditSectionName(e) { ...@@ -745,7 +742,7 @@ function saveEditSectionName(e) {
type: "POST", type: "POST",
dataType: "json", dataType: "json",
contentType: "application/json", contentType: "application/json",
data:JSON.stringify({ 'id' : id, 'metadata' : {'display_name' : display_name}, 'data': null, 'children' : null}) data:JSON.stringify({ 'id' : id, 'metadata' : {'display_name' : display_name}})
}).success(function() }).success(function()
{ {
$spinner.delay(250).fadeOut(250); $spinner.delay(250).fadeOut(250);
...@@ -785,7 +782,7 @@ function saveSetSectionScheduleDate(e) { ...@@ -785,7 +782,7 @@ function saveSetSectionScheduleDate(e) {
type: "POST", type: "POST",
dataType: "json", dataType: "json",
contentType: "application/json", contentType: "application/json",
data:JSON.stringify({ 'id' : id, 'metadata' : {'start' : start}, 'data': null, 'children' : null}) data:JSON.stringify({ 'id' : id, 'metadata' : {'start' : start}})
}).success(function() }).success(function()
{ {
var $thisSection = $('.courseware-section[data-id="' + id + '"]'); var $thisSection = $('.courseware-section[data-id="' + id + '"]');
......
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