mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Added post status saving (#16702)
no issue
<!-- Leave the line below if you'd like GitHub Copilot to generate a
summary from your commit -->
<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at ebd1973</samp>
This pull request adds support for storing and tracking the status of
posts in revisions. It introduces a new `post_status` column and
property in the `post` and `PostRevision` models, and updates the
`PostRevisions.formatInput` method to handle it.
This commit is contained in:
parent
3aec11328f
commit
f68936900c
3 changed files with 12 additions and 7 deletions
|
@ -913,7 +913,7 @@ Post = ghostBookshelf.Model.extend({
|
||||||
const revisionModels = await ghostBookshelf.model('PostRevision')
|
const revisionModels = await ghostBookshelf.model('PostRevision')
|
||||||
.findAll(Object.assign({
|
.findAll(Object.assign({
|
||||||
filter: `post_id:${model.id}`,
|
filter: `post_id:${model.id}`,
|
||||||
columns: ['id', 'lexical', 'created_at', 'author_id', 'title', 'reason']
|
columns: ['id', 'lexical', 'created_at', 'author_id', 'title', 'reason', 'post_status']
|
||||||
}, _.pick(options, 'transacting')));
|
}, _.pick(options, 'transacting')));
|
||||||
|
|
||||||
const revisions = revisionModels.toJSON();
|
const revisions = revisionModels.toJSON();
|
||||||
|
@ -923,7 +923,8 @@ Post = ghostBookshelf.Model.extend({
|
||||||
html: model.previous('html'),
|
html: model.previous('html'),
|
||||||
author_id: model.previous('updated_by'),
|
author_id: model.previous('updated_by'),
|
||||||
feature_image: model.previous('feature_image'),
|
feature_image: model.previous('feature_image'),
|
||||||
title: model.previous('title')
|
title: model.previous('title'),
|
||||||
|
post_status: model.previous('status')
|
||||||
};
|
};
|
||||||
const current = {
|
const current = {
|
||||||
id: model.id,
|
id: model.id,
|
||||||
|
@ -931,7 +932,8 @@ Post = ghostBookshelf.Model.extend({
|
||||||
html: model.get('html'),
|
html: model.get('html'),
|
||||||
author_id: authorId,
|
author_id: authorId,
|
||||||
feature_image: model.get('feature_image'),
|
feature_image: model.get('feature_image'),
|
||||||
title: model.get('title')
|
title: model.get('title'),
|
||||||
|
post_status: model.get('status')
|
||||||
};
|
};
|
||||||
|
|
||||||
// This can be refactored once we have the status stored in each revision
|
// This can be refactored once we have the status stored in each revision
|
||||||
|
|
|
@ -831,7 +831,7 @@ exports[`Posts API Create Can create a post with lexical 2: [headers] 1`] = `
|
||||||
Object {
|
Object {
|
||||||
"access-control-allow-origin": "http://127.0.0.1:2369",
|
"access-control-allow-origin": "http://127.0.0.1:2369",
|
||||||
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||||
"content-length": "5309",
|
"content-length": "5312",
|
||||||
"content-type": "application/json; charset=utf-8",
|
"content-type": "application/json; charset=utf-8",
|
||||||
"content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/,
|
"content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/,
|
||||||
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||||
|
@ -1261,7 +1261,7 @@ exports[`Posts API Update Can update a post with lexical 2: [headers] 1`] = `
|
||||||
Object {
|
Object {
|
||||||
"access-control-allow-origin": "http://127.0.0.1:2369",
|
"access-control-allow-origin": "http://127.0.0.1:2369",
|
||||||
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||||
"content-length": "5246",
|
"content-length": "5249",
|
||||||
"content-type": "application/json; charset=utf-8",
|
"content-type": "application/json; charset=utf-8",
|
||||||
"content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/,
|
"content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/,
|
||||||
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||||
|
@ -1371,7 +1371,7 @@ exports[`Posts API Update Can update a post with lexical 4: [headers] 1`] = `
|
||||||
Object {
|
Object {
|
||||||
"access-control-allow-origin": "http://127.0.0.1:2369",
|
"access-control-allow-origin": "http://127.0.0.1:2369",
|
||||||
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||||
"content-length": "6511",
|
"content-length": "6517",
|
||||||
"content-type": "application/json; charset=utf-8",
|
"content-type": "application/json; charset=utf-8",
|
||||||
"content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/,
|
"content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/,
|
||||||
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
* @property {string} feature_image
|
* @property {string} feature_image
|
||||||
* @property {string} title
|
* @property {string} title
|
||||||
* @property {string} reason
|
* @property {string} reason
|
||||||
|
* @property {string} post_status
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,6 +19,7 @@
|
||||||
* @property {string} feature_image
|
* @property {string} feature_image
|
||||||
* @property {string} title
|
* @property {string} title
|
||||||
* @property {string} reason
|
* @property {string} reason
|
||||||
|
* @property {string} post_status
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class PostRevisions {
|
class PostRevisions {
|
||||||
|
@ -104,7 +106,8 @@ class PostRevisions {
|
||||||
created_at_ts: Date.now() - offset,
|
created_at_ts: Date.now() - offset,
|
||||||
author_id: input.author_id,
|
author_id: input.author_id,
|
||||||
feature_image: input.feature_image,
|
feature_image: input.feature_image,
|
||||||
title: input.title
|
title: input.title,
|
||||||
|
post_status: input.post_status
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue