diff --git a/app/assets/javascripts/admin/models/admin_user.js b/app/assets/javascripts/admin/models/admin_user.js index c89b5409732..816690031be 100644 --- a/app/assets/javascripts/admin/models/admin_user.js +++ b/app/assets/javascripts/admin/models/admin_user.js @@ -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')) { diff --git a/app/assets/javascripts/discourse/controllers/user-card.js.es6 b/app/assets/javascripts/discourse/controllers/user-card.js.es6 index 2ea6b91e462..369bf7c81a1 100644 --- a/app/assets/javascripts/discourse/controllers/user-card.js.es6 +++ b/app/assets/javascripts/discourse/controllers/user-card.js.es6 @@ -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); diff --git a/app/assets/javascripts/discourse/models/user.js b/app/assets/javascripts/discourse/models/user.js index 70884339273..47e36a415e4 100644 --- a/app/assets/javascripts/discourse/models/user.js +++ b/app/assets/javascripts/discourse/models/user.js @@ -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