Commit ab4fd03d by Don Mitchell

Catch any and all save errors

parent b8c1dba1
...@@ -68,10 +68,18 @@ CMS.Models.Settings.CourseDetails = Backbone.Model.extend({ ...@@ -68,10 +68,18 @@ CMS.Models.Settings.CourseDetails = Backbone.Model.extend({
save_videosource: function(newsource) { save_videosource: function(newsource) {
// newsource either is <video youtube="speed:key, *"/> or just the "speed:key, *" string // newsource either is <video youtube="speed:key, *"/> or just the "speed:key, *" string
// returns the videosource for the preview which iss the key whose speed is closest to 1 // returns the videosource for the preview which iss the key whose speed is closest to 1
if (_.isEmpty(newsource) && !_.isEmpty(this.get('intro_video'))) this.save({'intro_video': null}); if (_.isEmpty(newsource) && !_.isEmpty(this.get('intro_video'))) this.save({'intro_video': null},
{ error : function(model, error) {
// this handler is for the client:server communication not the vlidation errors which handleValidationError catches
window.alert("Error during save: " + error.responseText);
}});
// TODO remove all whitespace w/in string // TODO remove all whitespace w/in string
else { else {
if (this.get('intro_video') !== newsource) this.save('intro_video', newsource); if (this.get('intro_video') !== newsource) this.save('intro_video', newsource,
{ error : function(model, error) {
// this handler is for the client:server communication not the vlidation errors which handleValidationError catches
window.alert("Error during save: " + error.responseText);
}});
} }
return this.videosourceSample(); return this.videosourceSample();
......
...@@ -57,7 +57,7 @@ CMS.Views.ValidatingView = Backbone.View.extend({ ...@@ -57,7 +57,7 @@ CMS.Views.ValidatingView = Backbone.View.extend({
this.clearValidationErrors(); this.clearValidationErrors();
this.model.save(field, newVal, { error : function(model, error) { this.model.save(field, newVal, { error : function(model, error) {
// this handler is for the client:server communication not the vlidation errors which handleValidationError catches // this handler is for the client:server communication not the vlidation errors which handleValidationError catches
if (error.responseText) window.alert("Error: " + error.responseText); window.alert("Error during save: " + error.responseText);
}}); }});
return true; return true;
} }
...@@ -230,7 +230,11 @@ CMS.Views.Settings.Details = CMS.Views.ValidatingView.extend({ ...@@ -230,7 +230,11 @@ CMS.Views.Settings.Details = CMS.Views.ValidatingView.extend({
time = 0; time = 0;
} }
var newVal = new Date(date.getTime() + time * 1000); var newVal = new Date(date.getTime() + time * 1000);
if (cacheModel.get(fieldName) != newVal) cacheModel.save(fieldName, newVal); if (cacheModel.get(fieldName) != newVal) cacheModel.save(fieldName, newVal,
{ error : function(model, error) {
// this handler is for the client:server communication not the vlidation errors which handleValidationError catches
window.alert("Error during save: " + error.responseText);
}});
} }
}; };
...@@ -279,7 +283,11 @@ CMS.Views.Settings.Details = CMS.Views.ValidatingView.extend({ ...@@ -279,7 +283,11 @@ CMS.Views.Settings.Details = CMS.Views.ValidatingView.extend({
}, },
removeSyllabus: function() { removeSyllabus: function() {
if (this.model.has('syllabus')) this.model.save({'syllabus': null}); if (this.model.has('syllabus')) this.model.save({'syllabus': null},
{ error : function(model, error) {
// this handler is for the client:server communication not the vlidation errors which handleValidationError catches
window.alert("Error during save: " + error.responseText);
}});
}, },
assetSyllabus : function() { assetSyllabus : function() {
...@@ -312,7 +320,11 @@ CMS.Views.Settings.Details = CMS.Views.ValidatingView.extend({ ...@@ -312,7 +320,11 @@ CMS.Views.Settings.Details = CMS.Views.ValidatingView.extend({
mirror.save(); mirror.save();
cachethis.clearValidationErrors(); cachethis.clearValidationErrors();
var newVal = mirror.getValue(); var newVal = mirror.getValue();
if (cachethis.model.get(field) != newVal) cachethis.model.save(field, newVal); if (cachethis.model.get(field) != newVal) cachethis.model.save(field, newVal,
{ error : function(model, error) {
// this handler is for the client:server communication not the vlidation errors which handleValidationError catches
window.alert("Error during save: " + error.responseText);
}});
} }
}); });
} }
...@@ -407,7 +419,11 @@ CMS.Views.Settings.Grading = CMS.Views.ValidatingView.extend({ ...@@ -407,7 +419,11 @@ CMS.Views.Settings.Grading = CMS.Views.ValidatingView.extend({
setGracePeriod : function(event) { setGracePeriod : function(event) {
event.data.clearValidationErrors(); event.data.clearValidationErrors();
var newVal = event.data.model.dateToGracePeriod($(event.currentTarget).timepicker('getTime')); var newVal = event.data.model.dateToGracePeriod($(event.currentTarget).timepicker('getTime'));
if (event.data.model.get('grace_period') != newVal) event.data.model.save('grace_period', newVal); if (event.data.model.get('grace_period') != newVal) event.data.model.save('grace_period', newVal,
{ error : function(model, error) {
// this handler is for the client:server communication not the vlidation errors which handleValidationError catches
window.alert("Error during save: " + error.responseText);
}});
}, },
updateModel : function(event) { updateModel : function(event) {
if (!this.selectorToField[event.currentTarget.id]) return; if (!this.selectorToField[event.currentTarget.id]) return;
...@@ -543,7 +559,11 @@ CMS.Views.Settings.Grading = CMS.Views.ValidatingView.extend({ ...@@ -543,7 +559,11 @@ CMS.Views.Settings.Grading = CMS.Views.ValidatingView.extend({
object[cutoff['designation']] = cutoff['cutoff'] / 100.0; object[cutoff['designation']] = cutoff['cutoff'] / 100.0;
return object; return object;
}, },
{})); {}),
{ error : function(model, error) {
// this handler is for the client:server communication not the vlidation errors which handleValidationError catches
window.alert("Error during save: " + error.responseText);
}});
}, },
addNewGrade: function(e) { addNewGrade: function(e) {
...@@ -674,7 +694,11 @@ CMS.Views.Settings.GraderView = CMS.Views.ValidatingView.extend({ ...@@ -674,7 +694,11 @@ CMS.Views.Settings.GraderView = CMS.Views.ValidatingView.extend({
} }
}, },
deleteModel : function(e) { deleteModel : function(e) {
this.model.destroy(); this.model.destroy(
{ error : function(model, error) {
// this handler is for the client:server communication not the vlidation errors which handleValidationError catches
window.alert("Error during save: " + error.responseText);
}});
e.preventDefault(); e.preventDefault();
} }
......
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