UX: improve user delete error message & return correct post count. (#13282)

Post count was incorrect on admin page causing confusion when admins attempted to delete users.
This commit is contained in:
Vinoth Kannan
2021-06-11 10:37:34 +05:30
committed by GitHub
parent 4681c670c0
commit cd6ab7bdd7
4 changed files with 9 additions and 2 deletions

View File

@ -420,7 +420,7 @@ class Admin::UsersController < Admin::AdminController
rescue UserDestroyer::PostsExistError
render json: {
deleted: false,
message: "User #{user.username} has #{user.post_count} posts, so they can't be deleted."
message: I18n.t("user.cannot_delete_has_posts", username: user.username, post_count: user.posts.joins(:topic).count),
}, status: 403
end
end