mirror of
https://github.com/flarum/framework.git
synced 2024-12-03 15:43:59 +08:00
38 lines
944 B
JavaScript
38 lines
944 B
JavaScript
|
import Ember from 'ember';
|
||
|
import DS from 'ember-data';
|
||
|
|
||
|
export default DS.Model.extend({
|
||
|
|
||
|
discussion: DS.belongsTo('discussion', {inverse: 'actualPosts'}),
|
||
|
number: DS.attr('number'),
|
||
|
|
||
|
time: DS.attr('string'),
|
||
|
user: DS.belongsTo('user'),
|
||
|
type: DS.attr('string'),
|
||
|
content: DS.attr('string'),
|
||
|
contentHtml: DS.attr('string'),
|
||
|
|
||
|
editTime: DS.attr('string'),
|
||
|
editUser: DS.belongsTo('user'),
|
||
|
edited: Ember.computed.notEmpty('editTime'),
|
||
|
|
||
|
deleteTime: DS.attr('string'),
|
||
|
deleteUser: DS.belongsTo('user'),
|
||
|
deleted: Ember.computed.notEmpty('deleteTime'),
|
||
|
|
||
|
replyTo: DS.belongsTo('post', {inverse: 'replies'}),
|
||
|
replyToNumber: DS.attr('number'),
|
||
|
replyToUser: DS.belongsTo('user'),
|
||
|
|
||
|
replies: DS.hasMany('post', {inverse: 'replyTo'}),
|
||
|
repliesCount: DS.attr('number'),
|
||
|
|
||
|
canEdit: DS.attr('boolean'),
|
||
|
canDelete: DS.attr('boolean'),
|
||
|
|
||
|
likes: function() {
|
||
|
return Math.floor(Math.random() * (Math.random() < 0.3 ? 10 : 1));
|
||
|
}.property()
|
||
|
|
||
|
});
|