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'),
|
|
|
|
markdown: DS.attr('string'),
|
|
|
|
html: DS.attr('string'),
|
|
|
|
image: DS.attr('string'),
|
|
|
|
featured: DS.attr('boolean'),
|
|
|
|
page: DS.attr('boolean'),
|
|
|
|
status: DS.attr('string'),
|
|
|
|
language: DS.attr('string'),
|
|
|
|
meta_title: DS.attr('string'),
|
|
|
|
meta_description: DS.attr('string'),
|
|
|
|
author: DS.belongsTo('user', { async: true }),
|
|
|
|
created_at: DS.attr('date'),
|
|
|
|
created_by: DS.belongsTo('user', { async: true }),
|
|
|
|
updated_at: DS.attr('date'),
|
|
|
|
updated_by: DS.belongsTo('user', { async: true }),
|
|
|
|
published_at: DS.attr('date'),
|
|
|
|
published_by: DS.belongsTo('user', { async: true }),
|
|
|
|
tags: DS.hasMany('tag', { async: true }),
|
2014-04-20 18:48:34 +04:00
|
|
|
|
|
|
|
generateSlug: function () {
|
2014-05-09 09:00:10 +04:00
|
|
|
var title = this.get('title'),
|
2014-05-29 19:14:36 +04:00
|
|
|
url;
|
|
|
|
|
|
|
|
if (!title) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
url = this.get('ghostPaths').apiUrl('slugs', 'post', encodeURIComponent(title));
|
2014-04-20 18:48:34 +04:00
|
|
|
|
|
|
|
return ic.ajax.request(url, {
|
2014-05-09 09:00:10 +04:00
|
|
|
type: 'GET'
|
|
|
|
});
|
2014-04-20 18:48:34 +04:00
|
|
|
},
|
2014-05-09 09:00:10 +04:00
|
|
|
|
|
|
|
validationErrors: 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({
|
|
|
|
message: "You must specify a title for the post."
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return validationErrors;
|
2014-05-09 09:00:10 +04:00
|
|
|
}.property('title')
|
2014-03-03 00:12:06 +04:00
|
|
|
});
|
|
|
|
|
2014-05-09 09:00:10 +04:00
|
|
|
export default Post;
|