mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Move post API to primary document format
closes #2580 - added new format to post API methods - added post object parsing and wrapping to admin - removed unused ‚user‘ object from API response - updated tests
This commit is contained in:
parent
3dbd11994c
commit
ff5ae21a9e
1 changed files with 14 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
|||
/*global Ghost, _, Backbone */
|
||||
/*global Ghost, _, Backbone, JSON */
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
|
@ -11,6 +11,10 @@
|
|||
blacklist: ['published', 'draft'],
|
||||
|
||||
parse: function (resp) {
|
||||
|
||||
if (resp.posts) {
|
||||
resp = resp.posts[0];
|
||||
}
|
||||
if (resp.status) {
|
||||
resp.published = resp.status === 'published';
|
||||
resp.draft = resp.status === 'draft';
|
||||
|
@ -39,6 +43,15 @@
|
|||
return tag.id === tagToRemove.id || tag.name === tagToRemove.name;
|
||||
});
|
||||
this.set('tags', tags);
|
||||
},
|
||||
sync: function (method, model, options) {
|
||||
//wrap post in {posts: [{...}]}
|
||||
if (method === 'create' || method === 'update') {
|
||||
options.data = JSON.stringify({posts: [this.attributes]});
|
||||
options.contentType = 'application/json';
|
||||
}
|
||||
|
||||
return Backbone.Model.prototype.sync.apply(this, arguments);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue