Ghost/ghost/admin/models/post.js
Sebastian Gierlinger 56eee1a84c Transfer Ownership
closes #3364 (special thanks to @jaswilli)
closes #3087
- added modal
- added controller
2014-07-23 12:41:31 +02:00

43 lines
1.6 KiB
JavaScript

import ValidationEngine from 'ghost/mixins/validation-engine';
import boundOneWay from 'ghost/utils/bound-one-way';
import NProgressSaveMixin from 'ghost/mixins/nprogress-save';
var Post = DS.Model.extend(NProgressSaveMixin, 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 }),
updated_at: DS.attr('moment-date'),
published_at: DS.attr('moment-date'),
published_by: DS.belongsTo('user', { async: true }),
tags: DS.hasMany('tag', { embedded: 'always' }),
titleScratch: boundOneWay('title'),
//## 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;