0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Tag API response to use parent rather than parent_id

Closes #2607
- added toJSON method to tag model
- parent_id attribute is replaced by parent
- integration tests will expect parent as an attribute
This commit is contained in:
Alan Richards 2014-04-22 23:46:53 -07:00
parent 190d31fb15
commit 5877e7d211
2 changed files with 10 additions and 1 deletions

View file

@ -27,6 +27,15 @@ Tag = ghostBookshelf.Model.extend({
posts: function () {
return this.belongsToMany(Posts);
},
toJSON: function (options) {
var attrs = ghostBookshelf.Model.prototype.toJSON.call(this, options);
attrs.parent = attrs.parent || attrs.parent_id;
delete attrs.parent_id;
return attrs;
}
});

View file

@ -14,7 +14,7 @@ var _ = require('lodash'),
settings: ['databaseVersion', 'dbHash', 'title', 'description', 'email', 'logo', 'cover', 'defaultLang',
"permalinks", 'postsPerPage', 'forceI18n', 'activeTheme', 'activeApps', 'installedApps',
'availableThemes', 'availableApps', 'nextUpdateCheck', 'displayUpdateNotification'],
tag: ['id', 'uuid', 'name', 'slug', 'description', 'parent_id',
tag: ['id', 'uuid', 'name', 'slug', 'description', 'parent',
'meta_title', 'meta_description', 'created_at', 'created_by', 'updated_at', 'updated_by'],
user: ['id', 'uuid', 'name', 'slug', 'email', 'image', 'cover', 'bio', 'website',
'location', 'accessibility', 'status', 'language', 'meta_title', 'meta_description',