mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 19:52:01 +03:00
8cbc6dc3b7
closes #2998 - update PostSerializer to use DS.EmbeddedRecordsMixin - create PostAdapter to include include=tags in query params for POST and PUT - set include=tags for various GET post requests - change PostModel to have { embedded: always } instead of { async: true } - update Ember-Data to beta8 from beta7 - make call to get tags from model in editor.edit route synchronous since the tags now exist in the store - change casper test to wait for call to posts api with `?include=tags`
44 lines
1.6 KiB
JavaScript
44 lines
1.6 KiB
JavaScript
import ValidationEngine from 'ghost/mixins/validation-engine';
|
|
|
|
var Post = DS.Model.extend(ValidationEngine, {
|
|
validationType: 'post',
|
|
|
|
uuid: DS.attr('string'),
|
|
title: DS.attr('string', {defaultValue: ''}),
|
|
slug: DS.attr('string'),
|
|
markdown: DS.attr('string', {defaultValue: ''}),
|
|
html: DS.attr('string'),
|
|
image: DS.attr('string'),
|
|
featured: DS.attr('boolean', {defaultValue: false}),
|
|
page: DS.attr('boolean', {defaultValue: false}),
|
|
status: DS.attr('string', {defaultValue: 'draft'}),
|
|
language: DS.attr('string', {defaultValue: 'en_US'}),
|
|
meta_title: DS.attr('string'),
|
|
meta_description: DS.attr('string'),
|
|
author: DS.belongsTo('user', { async: true }),
|
|
created_at: DS.attr('moment-date'),
|
|
created_by: DS.belongsTo('user', { async: true }),
|
|
updated_at: DS.attr('moment-date'),
|
|
updated_by: DS.belongsTo('user', { async: true }),
|
|
published_at: DS.attr('moment-date'),
|
|
published_by: DS.belongsTo('user', { async: true }),
|
|
tags: DS.hasMany('tag', { embedded: 'always' }),
|
|
|
|
//## Computed post properties
|
|
isPublished: Ember.computed.equal('status', 'published'),
|
|
isDraft: Ember.computed.equal('status', 'draft'),
|
|
|
|
// remove client-generated tags, which have `id: null`.
|
|
// Ember Data won't recognize/update them automatically
|
|
// when returned from the server with ids.
|
|
updateTags: function () {
|
|
var tags = this.get('tags'),
|
|
oldTags = tags.filterBy('id', null);
|
|
|
|
tags.removeObjects(oldTags);
|
|
oldTags.invoke('deleteRecord');
|
|
}
|
|
});
|
|
|
|
export default Post;
|