FIX: admin user page should show count of all posts, including private messages, so admins can delete them. This bug was making it impossible to delete users.

This commit is contained in:
Neil Lalonde 2017-03-17 17:01:45 -04:00
parent f5f54c1b77
commit 9ae8813a53
2 changed files with 5 additions and 1 deletions

View File

@ -91,4 +91,8 @@ class AdminDetailedUserSerializer < AdminUserSerializer
scope.can_view_action_logs?(object)
end
def post_count
object.posts.count
end
end

View File

@ -15,8 +15,8 @@ class UserDestroyer
# Returns a frozen instance of the User if the delete succeeded.
def destroy(user, opts={})
raise Discourse::InvalidParameters.new('user is nil') unless user and user.is_a?(User)
@guardian.ensure_can_delete_user!(user)
raise PostsExistError if !opts[:delete_posts] && user.posts.count != 0
@guardian.ensure_can_delete_user!(user)
User.transaction do