ea6c601b01
#closes #1655 - removed models as parameter for bookshelf-session - changed to read permittedAttributes from schema.js - changed updateTags to be executed at saved event - added validate to execute after saving event - added test for published_at = null (see #2015) - fixed typo in general.hbs
34 lines
756 B
JavaScript
34 lines
756 B
JavaScript
var User = require('./user').User,
|
|
Permission = require('./permission').Permission,
|
|
ghostBookshelf = require('./base'),
|
|
|
|
Role,
|
|
Roles;
|
|
|
|
Role = ghostBookshelf.Model.extend({
|
|
|
|
tableName: 'roles',
|
|
|
|
validate: function () {
|
|
ghostBookshelf.validator.check(this.get('name'), "Role name cannot be blank").notEmpty();
|
|
ghostBookshelf.validator.check(this.get('description'), "Role description cannot be blank").notEmpty();
|
|
},
|
|
|
|
users: function () {
|
|
return this.belongsToMany(User);
|
|
},
|
|
|
|
permissions: function () {
|
|
return this.belongsToMany(Permission);
|
|
}
|
|
});
|
|
|
|
Roles = ghostBookshelf.Collection.extend({
|
|
model: Role
|
|
});
|
|
|
|
module.exports = {
|
|
Role: Role,
|
|
Roles: Roles
|
|
};
|