2012-09-18 12:21:43 +09:00
|
|
|
|
Template.user_item.rendered = function(){
|
|
|
|
|
};
|
2012-09-18 15:43:37 +09:00
|
|
|
|
|
2012-10-03 16:33:28 +09:00
|
|
|
|
Template.user_item.helpers({
|
2012-10-11 08:23:52 +09:00
|
|
|
|
avatarUrl: function(){
|
2012-10-03 16:33:28 +09:00
|
|
|
|
return getAvatarUrl(this);
|
|
|
|
|
},
|
2012-10-11 08:23:52 +09:00
|
|
|
|
createdAtFormatted: function(){
|
2012-10-03 16:33:28 +09:00
|
|
|
|
return this.createdAt ? moment(this.createdAt).fromNow() : '–';
|
|
|
|
|
},
|
2012-10-11 08:23:52 +09:00
|
|
|
|
displayName: function(){
|
2012-10-03 16:33:28 +09:00
|
|
|
|
return getDisplayName(this);
|
|
|
|
|
},
|
|
|
|
|
email: function(){
|
|
|
|
|
return getEmail(this);
|
|
|
|
|
},
|
|
|
|
|
posts: function(){
|
|
|
|
|
return Posts.find({'userId':this._id});
|
|
|
|
|
},
|
2012-10-11 08:23:52 +09:00
|
|
|
|
postsCount: function(){
|
2012-10-03 16:33:28 +09:00
|
|
|
|
return Posts.find({'userId':this._id}).count();
|
|
|
|
|
},
|
|
|
|
|
comments: function(){
|
|
|
|
|
return Comments.find({'userId':this._id});
|
|
|
|
|
},
|
2012-10-11 08:23:52 +09:00
|
|
|
|
commentsCount: function(){
|
2012-10-03 16:33:28 +09:00
|
|
|
|
// Posts.find({'user_id':this._id}).forEach(function(post){console.log(post.headline);});
|
|
|
|
|
return Comments.find({'userId':this._id}).count();
|
2012-10-19 19:20:14 +09:00
|
|
|
|
},
|
|
|
|
|
userIsAdmin: function(){
|
|
|
|
|
return isAdmin(this);
|
2012-09-18 16:29:26 +09:00
|
|
|
|
}
|
2012-10-05 13:59:40 +09:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Template.user_item.events({
|
|
|
|
|
'click .invite-link': function(e, instance){
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
Meteor.users.update(instance.data._id,{
|
|
|
|
|
$set:{
|
|
|
|
|
isInvited: true
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
'click .uninvite-link': function(e, instance){
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
Meteor.users.update(instance.data._id,{
|
|
|
|
|
$set:{
|
|
|
|
|
isInvited: false
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
'click .admin-link': function(e, instance){
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
Meteor.users.update(instance.data._id,{
|
|
|
|
|
$set:{
|
|
|
|
|
isAdmin: true
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
'click .unadmin-link': function(e, instance){
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
Meteor.users.update(instance.data._id,{
|
|
|
|
|
$set:{
|
|
|
|
|
isAdmin: false
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
})
|