mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
Added email_only column to posts_meta table
closes https://github.com/TryGhost/Team/issues/893 - We need a place to store email-only flag and posts_meta is the best place for it
This commit is contained in:
parent
7ac8765170
commit
755a3a320e
7 changed files with 23 additions and 4 deletions
|
@ -52,7 +52,8 @@ const mapPost = (model, frame) => {
|
||||||
_(metaAttrs).filter((k) => {
|
_(metaAttrs).filter((k) => {
|
||||||
return (!frame.options.columns || (frame.options.columns && frame.options.columns.includes(k)));
|
return (!frame.options.columns || (frame.options.columns && frame.options.columns.includes(k)));
|
||||||
}).each((attr) => {
|
}).each((attr) => {
|
||||||
jsonModel[attr] = _.get(jsonModel.posts_meta, attr) || null;
|
const defaultValue = (attr === 'email_only') ? false : null;
|
||||||
|
jsonModel[attr] = _.get(jsonModel.posts_meta, attr) || defaultValue;
|
||||||
});
|
});
|
||||||
delete jsonModel.posts_meta;
|
delete jsonModel.posts_meta;
|
||||||
|
|
||||||
|
@ -89,6 +90,7 @@ const mapPage = (model, frame) => {
|
||||||
|
|
||||||
delete jsonModel.email_subject;
|
delete jsonModel.email_subject;
|
||||||
delete jsonModel.email_recipient_filter;
|
delete jsonModel.email_recipient_filter;
|
||||||
|
delete jsonModel.email_only;
|
||||||
|
|
||||||
return jsonModel;
|
return jsonModel;
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
const {createAddColumnMigration} = require('../../utils');
|
||||||
|
|
||||||
|
module.exports = createAddColumnMigration('posts_meta', 'email_only', {
|
||||||
|
type: 'bool',
|
||||||
|
nullable: false,
|
||||||
|
defaultTo: false
|
||||||
|
});
|
|
@ -74,7 +74,8 @@ module.exports = {
|
||||||
email_subject: {type: 'string', maxlength: 300, nullable: true},
|
email_subject: {type: 'string', maxlength: 300, nullable: true},
|
||||||
frontmatter: {type: 'text', maxlength: 65535, nullable: true},
|
frontmatter: {type: 'text', maxlength: 65535, nullable: true},
|
||||||
feature_image_alt: {type: 'string', maxlength: 191, nullable: true, validations: {isLength: {max: 125}}},
|
feature_image_alt: {type: 'string', maxlength: 191, nullable: true, validations: {isLength: {max: 125}}},
|
||||||
feature_image_caption: {type: 'text', maxlength: 65535, nullable: true}
|
feature_image_caption: {type: 'text', maxlength: 65535, nullable: true},
|
||||||
|
email_only: {type: 'bool', nullable: false, defaultTo: false}
|
||||||
},
|
},
|
||||||
users: {
|
users: {
|
||||||
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
|
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
|
||||||
|
|
|
@ -4,6 +4,12 @@ const urlUtils = require('../../shared/url-utils');
|
||||||
const PostsMeta = ghostBookshelf.Model.extend({
|
const PostsMeta = ghostBookshelf.Model.extend({
|
||||||
tableName: 'posts_meta',
|
tableName: 'posts_meta',
|
||||||
|
|
||||||
|
defaults: function defaults() {
|
||||||
|
return {
|
||||||
|
email_only: false
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
formatOnWrite(attrs) {
|
formatOnWrite(attrs) {
|
||||||
['og_image', 'twitter_image'].forEach((attr) => {
|
['og_image', 'twitter_image'].forEach((attr) => {
|
||||||
if (attrs[attr]) {
|
if (attrs[attr]) {
|
||||||
|
|
|
@ -39,6 +39,8 @@ describe('Posts API', function () {
|
||||||
localUtils.API.checkResponse(jsonResponse.posts[0], 'post');
|
localUtils.API.checkResponse(jsonResponse.posts[0], 'post');
|
||||||
localUtils.API.checkResponse(jsonResponse.meta.pagination, 'pagination');
|
localUtils.API.checkResponse(jsonResponse.meta.pagination, 'pagination');
|
||||||
_.isBoolean(jsonResponse.posts[0].featured).should.eql(true);
|
_.isBoolean(jsonResponse.posts[0].featured).should.eql(true);
|
||||||
|
_.isBoolean(jsonResponse.posts[0].email_only).should.eql(true);
|
||||||
|
jsonResponse.posts[0].email_only.should.eql(false);
|
||||||
|
|
||||||
// Ensure default order
|
// Ensure default order
|
||||||
jsonResponse.posts[0].slug.should.eql('scheduled-post');
|
jsonResponse.posts[0].slug.should.eql('scheduled-post');
|
||||||
|
|
|
@ -69,7 +69,8 @@ const expectedProperties = {
|
||||||
'meta_title',
|
'meta_title',
|
||||||
'meta_description',
|
'meta_description',
|
||||||
'email_subject',
|
'email_subject',
|
||||||
'frontmatter'
|
'frontmatter',
|
||||||
|
'email_only'
|
||||||
],
|
],
|
||||||
|
|
||||||
page: [
|
page: [
|
||||||
|
|
|
@ -32,7 +32,7 @@ const defaultSettings = require('../../../../core/server/data/schema/default-set
|
||||||
*/
|
*/
|
||||||
describe('DB version integrity', function () {
|
describe('DB version integrity', function () {
|
||||||
// Only these variables should need updating
|
// Only these variables should need updating
|
||||||
const currentSchemaHash = 'a2248eaa72a9d08c3753b90a9436dbe3';
|
const currentSchemaHash = '6becb030fb054078d95f927bcfcd4f5e';
|
||||||
const currentFixturesHash = '97283c575b1f6c84c27db6e1b1be21d4';
|
const currentFixturesHash = '97283c575b1f6c84c27db6e1b1be21d4';
|
||||||
const currentSettingsHash = 'aa3fcbc8ab119b630aeda7366ead5493';
|
const currentSettingsHash = 'aa3fcbc8ab119b630aeda7366ead5493';
|
||||||
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';
|
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';
|
||||||
|
|
Loading…
Add table
Reference in a new issue