mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 11:53:44 +08:00
refactor fix in 67c4c90159
This commit is contained in:
parent
acc62f2ec2
commit
f9f54e2626
|
@ -298,9 +298,7 @@ Discourse.AdminUser = Discourse.User.extend({
|
|||
});
|
||||
},
|
||||
|
||||
deleteForbidden: function() {
|
||||
return (!this.get('can_be_deleted') || this.get('post_count') > 0);
|
||||
}.property('post_count'),
|
||||
deleteForbidden: Em.computed.not("canBeDeleted"),
|
||||
|
||||
deleteExplanation: function() {
|
||||
if (this.get('deleteForbidden')) {
|
||||
|
|
|
@ -20,8 +20,7 @@ export default ObjectController.extend({
|
|||
isSuspended: Em.computed.notEmpty('user.suspend_reason'),
|
||||
showBadges: Discourse.computed.setting('enable_badges'),
|
||||
showMoreBadges: Em.computed.gt('moreBadgesCount', 0),
|
||||
canDelete: Em.computed.not("user.deleteForbidden"),
|
||||
showDelete: Em.computed.and("viewingAdmin", "showName", "canDelete"),
|
||||
showDelete: Em.computed.and("viewingAdmin", "showName", "user.canBeDeleted"),
|
||||
|
||||
moreBadgesCount: function() {
|
||||
return this.get('user.badge_count') - this.get('user.featured_user_badges.length');
|
||||
|
@ -74,14 +73,8 @@ export default ObjectController.extend({
|
|||
self.set('cardTarget', target);
|
||||
|
||||
Discourse.User.findByUsername(username).then(function (user) {
|
||||
|
||||
// A bit hacky. If viewing admin, wrap it in Discourse.AdminUser
|
||||
// TODO: Restructure this to be cleaner
|
||||
var wrapped = user;
|
||||
if (self.get('viewingAdmin')) {
|
||||
wrapped = Discourse.AdminUser.create(user);
|
||||
}
|
||||
self.setProperties({ user: wrapped, avatar: user, visible: true});
|
||||
user = Discourse.User.create(user);
|
||||
self.setProperties({ user: user, avatar: user, visible: true});
|
||||
self.appEvents.trigger('usercard:shown');
|
||||
}).finally(function(){
|
||||
self.set('userLoading', null);
|
||||
|
|
|
@ -11,6 +11,9 @@ Discourse.User = Discourse.Model.extend({
|
|||
hasPMs: Em.computed.gt("private_messages_stats.all", 0),
|
||||
hasStartedPMs: Em.computed.gt("private_messages_stats.mine", 0),
|
||||
hasUnreadPMs: Em.computed.gt("private_messages_stats.unread", 0),
|
||||
hasPosted: Em.computed.gt("post_count", 0),
|
||||
hasNotPosted: Em.computed.not("hasPosted"),
|
||||
canBeDeleted: Em.computed.and("can_be_deleted", "hasNotPosted"),
|
||||
|
||||
/**
|
||||
The user's stream
|
||||
|
|
Loading…
Reference in New Issue
Block a user