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