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:
parent
f5f54c1b77
commit
9ae8813a53
|
@ -91,4 +91,8 @@ class AdminDetailedUserSerializer < AdminUserSerializer
|
|||
scope.can_view_action_logs?(object)
|
||||
end
|
||||
|
||||
def post_count
|
||||
object.posts.count
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue