2014-07-05 11:24:28 +09:00
|
|
|
|
Template[getTemplate('user_item')].helpers({
|
2013-10-09 20:50:26 +09:00
|
|
|
|
createdAtFormatted: function(){
|
|
|
|
|
return this.createdAt ? moment(this.createdAt).fromNow() : '–';
|
|
|
|
|
},
|
|
|
|
|
displayName: function(){
|
|
|
|
|
return getDisplayName(this);
|
|
|
|
|
},
|
2013-11-08 11:15:02 +09:00
|
|
|
|
getEmail: function(){
|
2013-10-09 20:50:26 +09:00
|
|
|
|
return getEmail(this);
|
|
|
|
|
},
|
|
|
|
|
posts: function(){
|
|
|
|
|
return Posts.find({'userId':this._id});
|
|
|
|
|
},
|
|
|
|
|
comments: function(){
|
|
|
|
|
return Comments.find({'userId':this._id});
|
|
|
|
|
},
|
|
|
|
|
userIsAdmin: function(){
|
|
|
|
|
return isAdmin(this);
|
2013-10-26 10:37:32 +09:00
|
|
|
|
},
|
2013-11-14 10:49:37 +09:00
|
|
|
|
getProfileUrl: function () {
|
2013-10-26 10:37:32 +09:00
|
|
|
|
return getProfileUrl(this);
|
2013-11-08 11:10:23 +09:00
|
|
|
|
},
|
|
|
|
|
getKarma: function() {
|
|
|
|
|
return Math.round(100*this.karma)/100;
|
2013-11-14 10:49:37 +09:00
|
|
|
|
},
|
|
|
|
|
getInvitedUserProfileUrl: function () {
|
|
|
|
|
var user = Meteor.users.findOne(this.invitedId);
|
|
|
|
|
return getProfileUrl(user);
|
2013-10-09 20:50:26 +09:00
|
|
|
|
}
|
2012-10-05 13:59:40 +09:00
|
|
|
|
});
|
|
|
|
|
|
2014-07-05 11:24:28 +09:00
|
|
|
|
Template[getTemplate('user_item')].events({
|
2013-10-09 20:50:26 +09:00
|
|
|
|
'click .invite-link': function(e, instance){
|
|
|
|
|
e.preventDefault();
|
2014-08-01 13:15:58 +02:00
|
|
|
|
Meteor.call('inviteUser', { userId : instance.data._id });
|
2013-10-09 20:50:26 +09:00
|
|
|
|
},
|
|
|
|
|
'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
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
'click .delete-link': function(e, instance){
|
|
|
|
|
e.preventDefault();
|
2013-11-09 02:02:05 +01:00
|
|
|
|
if(confirm(i18n.t("Are you sure you want to delete ")+getDisplayName(instance.data)+"?"))
|
2013-10-09 20:50:26 +09:00
|
|
|
|
Meteor.users.remove(instance.data._id);
|
|
|
|
|
}
|
2014-09-16 15:18:27 -04:00
|
|
|
|
});
|