2014-05-09 09:00:10 +04:00
|
|
|
var Post = DS.Model.extend({
|
|
|
|
uuid: DS.attr('string'),
|
|
|
|
title: DS.attr('string'),
|
|
|
|
slug: DS.attr('string'),
|
2014-05-31 22:32:22 +04:00
|
|
|
markdown: DS.attr('string', {defaultValue: ''}),
|
2014-05-09 09:00:10 +04:00
|
|
|
html: DS.attr('string'),
|
|
|
|
image: DS.attr('string'),
|
2014-05-31 22:32:22 +04:00
|
|
|
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'}),
|
2014-05-09 09:00:10 +04:00
|
|
|
meta_title: DS.attr('string'),
|
|
|
|
meta_description: DS.attr('string'),
|
|
|
|
author: DS.belongsTo('user', { async: true }),
|
2014-06-05 20:04:59 +04:00
|
|
|
created_at: DS.attr('moment-date'),
|
2014-05-09 09:00:10 +04:00
|
|
|
created_by: DS.belongsTo('user', { async: true }),
|
2014-06-05 20:04:59 +04:00
|
|
|
updated_at: DS.attr('moment-date'),
|
2014-05-09 09:00:10 +04:00
|
|
|
updated_by: DS.belongsTo('user', { async: true }),
|
2014-06-05 20:04:59 +04:00
|
|
|
published_at: DS.attr('moment-date'),
|
2014-05-09 09:00:10 +04:00
|
|
|
published_by: DS.belongsTo('user', { async: true }),
|
|
|
|
tags: DS.hasMany('tag', { async: true }),
|
2014-06-09 00:48:14 +04:00
|
|
|
|
|
|
|
//## Computed post properties
|
|
|
|
isPublished: Ember.computed.equal('status', 'published'),
|
|
|
|
isDraft: Ember.computed.equal('status', 'draft'),
|
2014-05-09 09:00:10 +04:00
|
|
|
|
2014-05-31 22:32:22 +04:00
|
|
|
validate: function () {
|
2014-04-20 18:48:34 +04:00
|
|
|
var validationErrors = [];
|
|
|
|
|
2014-05-09 09:00:10 +04:00
|
|
|
if (!this.get('title.length')) {
|
2014-04-20 18:48:34 +04:00
|
|
|
validationErrors.push({
|
2014-06-02 00:53:16 +04:00
|
|
|
message: 'You must specify a title for the post.'
|
2014-04-20 18:48:34 +04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return validationErrors;
|
2014-05-09 09:00:10 +04:00
|
|
|
}.property('title')
|
2014-03-03 00:12:06 +04:00
|
|
|
});
|
|
|
|
|
2014-06-09 00:48:14 +04:00
|
|
|
export default Post;
|