Ghost/core/server/models/index.js
Jacob Gable 9369dd3bf7 Add app permission checking to canThis
- Pass permissions loading to buildObjectTypeHandlers to eliminate
shared state
- Load both app and user permissions to check
- Check app permissions if present
- Create apps table and App model
- Move effectiveUserPermissions to permissions/effective
- Change permissable interface to take context; user and app.
- Add unit tests for app canThis checks and effective permissions
2014-04-16 18:06:39 +02:00

37 lines
1.1 KiB
JavaScript

var migrations = require('../data/migration'),
_ = require('lodash'),
when = require('when');
module.exports = {
Post: require('./post').Post,
User: require('./user').User,
Role: require('./role').Role,
Permission: require('./permission').Permission,
Settings: require('./settings').Settings,
Tag: require('./tag').Tag,
Base: require('./base'),
Session: require('./session').Session,
App: require('./app').App,
init: function () {
return migrations.init();
},
// ### deleteAllContent
// Delete all content from the database (posts, tags, tags_posts)
deleteAllContent: function () {
var self = this;
return self.Post.browse().then(function (posts) {
return when.all(_.map(posts.toJSON(), function (post) {
return self.Post.destroy(post.id);
}));
}).then(function () {
return self.Tag.browse().then(function (tags) {
return when.all(_.map(tags.toJSON(), function (tag) {
return self.Tag.destroy(tag.id);
}));
});
});
}
};