Files
edx-platform/cms/static/js/models/group.js
2014-12-05 09:52:26 -05:00

39 lines
936 B
JavaScript

define([
'backbone', 'underscore', 'underscore.string', 'gettext',
'backbone.associations'
], function(Backbone, _, str, gettext) {
'use strict';
var Group = Backbone.AssociatedModel.extend({
defaults: function() {
return {
name: '',
version: 1,
order: null
};
},
isEmpty: function() {
return !this.get('name');
},
toJSON: function() {
return {
id: this.get('id'),
name: this.get('name'),
version: this.get('version')
};
},
validate: function(attrs) {
if (!str.trim(attrs.name)) {
return {
message: gettext('Group name is required'),
attributes: { name: true }
};
}
}
});
return Group;
});