2019-05-27 11:37:05 +03:00
|
|
|
import {Factory} from 'ember-cli-mirage';
|
2018-03-13 14:17:29 +03:00
|
|
|
import {isEmpty} from '@ember/utils';
|
2017-01-02 21:49:44 +03:00
|
|
|
|
|
|
|
export default Factory.extend({
|
2018-03-26 13:41:45 +03:00
|
|
|
codeinjectionFoot: null,
|
|
|
|
codeinjectionHead: null,
|
|
|
|
createdAt: '2015-09-11T09:44:29.871Z',
|
|
|
|
createdBy: 1,
|
|
|
|
customExcerpt: null,
|
|
|
|
customTemplate: null,
|
2018-01-05 18:38:23 +03:00
|
|
|
description(i) { return `Title for post ${i}.`; },
|
2017-01-02 21:49:44 +03:00
|
|
|
featured: false,
|
2018-03-26 13:41:45 +03:00
|
|
|
featureImage(i) { return `/content/images/2015/10/post-${i}.jpg`; },
|
|
|
|
html(i) { return `<p>HTML for post ${i}.</p>`; },
|
2019-10-01 16:00:53 +03:00
|
|
|
visibility: 'public',
|
2018-01-05 18:38:23 +03:00
|
|
|
metaDescription(i) { return `Meta description for post ${i}.`; },
|
|
|
|
metaTitle(i) { return `Meta Title for post ${i}`; },
|
2018-03-26 13:41:45 +03:00
|
|
|
ogDescription: null,
|
|
|
|
ogImage: null,
|
|
|
|
ogTitle: null,
|
2019-02-26 09:37:23 +03:00
|
|
|
excerpt(i) { return `Excerpt for post ${i}.`; },
|
2018-03-26 13:41:45 +03:00
|
|
|
plaintext(i) { return `Plaintext for post ${i}.`; },
|
2017-01-02 21:49:44 +03:00
|
|
|
publishedAt: '2015-12-19T16:25:07.000Z',
|
|
|
|
publishedBy: 1,
|
2019-05-27 11:37:05 +03:00
|
|
|
status(i) {
|
|
|
|
let statuses = ['draft', 'published', 'scheduled'];
|
|
|
|
return statuses[i % statuses.length];
|
|
|
|
},
|
2018-03-26 13:41:45 +03:00
|
|
|
title(i) { return `Post ${i}`; },
|
|
|
|
twitterDescription: null,
|
|
|
|
twitterImage: null,
|
|
|
|
twitterTitle: null,
|
2019-11-04 09:15:13 +03:00
|
|
|
emailSubject: null,
|
2018-03-26 13:41:45 +03:00
|
|
|
updatedAt: '2015-10-19T16:25:07.756Z',
|
|
|
|
updatedBy: 1,
|
2018-03-13 14:17:29 +03:00
|
|
|
uuid(i) { return `post-${i}`; },
|
|
|
|
|
|
|
|
authors() { return []; },
|
|
|
|
tags() { return []; },
|
|
|
|
|
|
|
|
afterCreate(post, server) {
|
|
|
|
if (isEmpty(post.authors)) {
|
|
|
|
let user = server.schema.users.find(1);
|
|
|
|
|
|
|
|
if (!user) {
|
|
|
|
let role = server.schema.roles.find({name: 'Administrator'}) || server.create('role', {name: 'Administrator'});
|
|
|
|
user = server.create('user', {roles: [role]});
|
|
|
|
}
|
|
|
|
|
|
|
|
post.authors = [user];
|
|
|
|
post.save();
|
|
|
|
}
|
|
|
|
}
|
2017-01-02 21:49:44 +03:00
|
|
|
});
|