diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index bc7ff0c08..fb26e71e7 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -36,6 +36,7 @@ module Admin def show @user = User.find(params[:id]) set_current_tab(params[:tab]) + set_banishable_user set_feedback_messages set_related_reactions set_user_details @@ -305,5 +306,10 @@ module Admin "overview" end end + + def set_banishable_user + @banishable_user = (@user.comments.where("created_at < ?", 100.days.ago).empty? && + @user.created_at < 100.days.ago) || current_user.super_admin? || current_user.support_admin? + end end end diff --git a/app/views/admin/users/show/profile/actions/_banish.html.erb b/app/views/admin/users/show/profile/actions/_banish.html.erb index 0ca9dc6ac..a5bb7f587 100644 --- a/app/views/admin/users/show/profile/actions/_banish.html.erb +++ b/app/views/admin/users/show/profile/actions/_banish.html.erb @@ -1,13 +1,6 @@
- <% if @user.comments.where("created_at < ?", 100.days.ago).empty? && @user.created_at < 100.days.ago %> -

This action is irreversible.

-

Once banished, we will delete all content created by <%= @user.name %> and change their username to @spam_###.

-

Be careful with this action.

- <%= form_for(@user, url: banish_admin_user_path(@user), html: { method: :post, onsubmit: "return confirm('Are you sure? This action is irreversible. Banishing will delete all content by #{@user.name} and change their username to @spam_###.')", id: nil }) do %> - - <% end %> - <% elsif current_user.super_admin? || current_user.support_admin? %> + <% if @banishable_user %>

This action is irreversible.

Once banished, we will delete all content created by <%= @user.name %> and change their username to @spam_###.

Be careful with this action.