Commit f9a10855 by David Baumgold

Add notes about JS validation functions returning non-i18n error messages

parent 44185c3a
...@@ -57,6 +57,8 @@ CMS.Models.Textbook = Backbone.AssociatedModel.extend({ ...@@ -57,6 +57,8 @@ CMS.Models.Textbook = Backbone.AssociatedModel.extend({
chapters: this.get('chapters').toJSON() chapters: this.get('chapters').toJSON()
}; };
}, },
// NOTE: validation functions should return non-internationalized error
// messages. The messages will be passed through gettext in the template.
validate: function(attrs, options) { validate: function(attrs, options) {
if (!attrs.name) { if (!attrs.name) {
return { return {
...@@ -129,6 +131,8 @@ CMS.Models.Chapter = Backbone.AssociatedModel.extend({ ...@@ -129,6 +131,8 @@ CMS.Models.Chapter = Backbone.AssociatedModel.extend({
url: this.get('asset_path') url: this.get('asset_path')
}; };
}, },
// NOTE: validation functions should return non-internationalized error
// messages. The messages will be passed through gettext in the template.
validate: function(attrs, options) { validate: function(attrs, options) {
if(!attrs.name && !attrs.asset_path) { if(!attrs.name && !attrs.asset_path) {
return { return {
...@@ -169,6 +173,8 @@ CMS.Models.FileUpload = Backbone.Model.extend({ ...@@ -169,6 +173,8 @@ CMS.Models.FileUpload = Backbone.Model.extend({
"totalBytes": 0, "totalBytes": 0,
"finished": false "finished": false
}, },
// NOTE: validation functions should return non-internationalized error
// messages. The messages will be passed through gettext in the template.
validate: function(attrs, options) { validate: function(attrs, options) {
if(attrs.selectedFile && attrs.selectedFile.type !== "application/pdf") { if(attrs.selectedFile && attrs.selectedFile.type !== "application/pdf") {
return { return {
......
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