mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-13 22:41:32 -05:00
41cef386bc
closes #2138 - Adds new models for AppField and AppSetting - Removed permitted attributes from App model (handled by base) - Added reference from Post to AppFields - Added fixture data to DataGenerator - Added integration tests for Apps, AppSettings, AppFields - Added import for Apps - Added app_fields to default fixtures
32 lines
No EOL
1.1 KiB
JavaScript
32 lines
No EOL
1.1 KiB
JavaScript
var ghostBookshelf = require('./base'),
|
|
Post = require('./post').Post,
|
|
AppField,
|
|
AppFields;
|
|
|
|
AppField = ghostBookshelf.Model.extend({
|
|
tableName: 'app_fields',
|
|
|
|
validate: function () {
|
|
ghostBookshelf.validator.check(this.get('key'), 'Key cannot be blank').notEmpty();
|
|
ghostBookshelf.validator.check(this.get('key'), 'Key maximum length is 150 characters.').len(0, 150);
|
|
ghostBookshelf.validator.check(this.get('app_id'), 'App cannot be blank').notEmpty();
|
|
ghostBookshelf.validator.check(this.get('type'), 'Type maximum length is 150 characters.').len(0, 150);
|
|
ghostBookshelf.validator.check(this.get('relatable_id'), 'Relatable id cannot be blank').notEmpty();
|
|
ghostBookshelf.validator.check(this.get('relatable_type'), 'Relatable type cannot be blank').notEmpty();
|
|
|
|
return true;
|
|
},
|
|
|
|
post: function () {
|
|
return this.morphOne(Post, 'relatable');
|
|
}
|
|
});
|
|
|
|
AppFields = ghostBookshelf.Collection.extend({
|
|
model: AppField
|
|
});
|
|
|
|
module.exports = {
|
|
AppField: AppField,
|
|
AppFields: AppFields
|
|
}; |