mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-30 14:22:07 +03:00
d587a845d4
issue #632 - removed old schemas - updated base model to reflect all of the consistent behaviours and properties across the models - updated all models to match the new schema TODO - no fixtures are currently loaded except settings - need to rename properties across the codebase
36 lines
891 B
JavaScript
36 lines
891 B
JavaScript
var GhostBookshelf = require('./base'),
|
|
User = require('./user').User,
|
|
Role = require('./role').Role,
|
|
Permission,
|
|
Permissions;
|
|
|
|
Permission = GhostBookshelf.Model.extend({
|
|
|
|
tableName: 'permissions',
|
|
|
|
permittedAttributes: ['id', 'uuid', 'name', 'object_type', 'action_type', 'object_id', 'created_at', 'created_by',
|
|
'updated_at', 'updated_by'],
|
|
|
|
|
|
validate: function () {
|
|
// TODO: validate object_type, action_type and object_id
|
|
GhostBookshelf.validator.check(this.get('name'), "Permission name cannot be blank").notEmpty();
|
|
},
|
|
|
|
roles: function () {
|
|
return this.belongsToMany(Role);
|
|
},
|
|
|
|
users: function () {
|
|
return this.belongsToMany(User);
|
|
}
|
|
});
|
|
|
|
Permissions = GhostBookshelf.Collection.extend({
|
|
model: Permission
|
|
});
|
|
|
|
module.exports = {
|
|
Permission: Permission,
|
|
Permissions: Permissions
|
|
}; |