Only update data in modules that have been set when passing into save_item, and don't force callers to set everything
This commit is contained in:
@@ -574,11 +574,11 @@ def save_item(request):
|
||||
|
||||
store = _modulestore(Location(item_location));
|
||||
|
||||
if request.POST['data'] is not None:
|
||||
if request.POST.get('data') is not None:
|
||||
data = request.POST['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']
|
||||
store.update_children(item_location, children)
|
||||
|
||||
@@ -587,7 +587,7 @@ def save_item(request):
|
||||
# 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
|
||||
# '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']
|
||||
# fetch original
|
||||
existing_item = modulestore().get_item(item_location)
|
||||
|
||||
@@ -1,6 +1,2 @@
|
||||
class CMS.Models.Module extends Backbone.Model
|
||||
url: '/save_item'
|
||||
defaults:
|
||||
data: null
|
||||
children: null
|
||||
metadata: null
|
||||
|
||||
@@ -218,7 +218,7 @@ function onUnitReordered() {
|
||||
type: "POST",
|
||||
dataType: "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() {
|
||||
type: "POST",
|
||||
dataType: "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() {
|
||||
type: "POST",
|
||||
dataType: "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() {
|
||||
metadata['start'] = getEdxTimeFromDateTimeInputs('start_date', 'start_time');
|
||||
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({
|
||||
url: "/save_item",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:JSON.stringify({ 'id' : id, 'metadata' : metadata, 'data': null, 'children' : children}),
|
||||
data:JSON.stringify({ 'id' : id, 'metadata' : metadata}),
|
||||
success: function() {
|
||||
$spinner.delay(500).fadeOut(150);
|
||||
},
|
||||
@@ -745,7 +742,7 @@ function saveEditSectionName(e) {
|
||||
type: "POST",
|
||||
dataType: "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()
|
||||
{
|
||||
$spinner.delay(250).fadeOut(250);
|
||||
@@ -785,7 +782,7 @@ function saveSetSectionScheduleDate(e) {
|
||||
type: "POST",
|
||||
dataType: "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()
|
||||
{
|
||||
var $thisSection = $('.courseware-section[data-id="' + id + '"]');
|
||||
|
||||
Reference in New Issue
Block a user