mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Refactored Pages API v3/canary controllers
refs https://github.com/TryGhost/Team/issues/949
refs e64274bb45
- This refactor is needed to bring the code in line with the rest of pages API controllers
- Next step will extract shared code patterns into a separate module
This commit is contained in:
parent
87ad210624
commit
accf0c645a
2 changed files with 42 additions and 44 deletions
|
@ -147,9 +147,9 @@ module.exports = {
|
||||||
docName: 'posts',
|
docName: 'posts',
|
||||||
unsafeAttrs: UNSAFE_ATTRS
|
unsafeAttrs: UNSAFE_ATTRS
|
||||||
},
|
},
|
||||||
query(frame) {
|
async query(frame) {
|
||||||
return models.Post.edit(frame.data.pages[0], frame.options)
|
const model = await models.Post.edit(frame.data.pages[0], frame.options);
|
||||||
.then((model) => {
|
|
||||||
if (
|
if (
|
||||||
model.get('status') === 'published' && model.wasChanged() ||
|
model.get('status') === 'published' && model.wasChanged() ||
|
||||||
model.get('status') === 'draft' && model.previous('status') === 'published'
|
model.get('status') === 'draft' && model.previous('status') === 'published'
|
||||||
|
@ -169,7 +169,6 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -147,9 +147,9 @@ module.exports = {
|
||||||
docName: 'posts',
|
docName: 'posts',
|
||||||
unsafeAttrs: UNSAFE_ATTRS
|
unsafeAttrs: UNSAFE_ATTRS
|
||||||
},
|
},
|
||||||
query(frame) {
|
async query(frame) {
|
||||||
return models.Post.edit(frame.data.pages[0], frame.options)
|
const model = await models.Post.edit(frame.data.pages[0], frame.options);
|
||||||
.then((model) => {
|
|
||||||
if (
|
if (
|
||||||
model.get('status') === 'published' && model.wasChanged() ||
|
model.get('status') === 'published' && model.wasChanged() ||
|
||||||
model.get('status') === 'draft' && model.previous('status') === 'published'
|
model.get('status') === 'draft' && model.previous('status') === 'published'
|
||||||
|
@ -169,7 +169,6 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue