diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 26e9151d9..d2ebd668d 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -239,12 +239,11 @@ class UsersController < ApplicationController end def bulk_lock - @users = User.logged.where(id: params[:ids]).where.not(id: User.current) - (render_404; return) unless @users.any? + bulk_update_status(params[:ids], User::STATUS_LOCKED) + end - @users.update_all status: User::STATUS_LOCKED - flash[:notice] = l(:notice_successful_update) - redirect_to users_path + def bulk_unlock + bulk_update_status(params[:ids], User::STATUS_ACTIVE) end private @@ -261,4 +260,13 @@ class UsersController < ApplicationController rescue ActiveRecord::RecordNotFound render_404 end + + def bulk_update_status(user_ids, status) + users = User.logged.where(id: user_ids).where.not(id: User.current) + (render_404; return) unless users.any? + + users.update_all status: status + flash[:notice] = l(:notice_successful_update) + redirect_to users_path + end end diff --git a/app/views/context_menus/users.html.erb b/app/views/context_menus/users.html.erb index c47b55fd2..93fe061e6 100644 --- a/app/views/context_menus/users.html.erb +++ b/app/views/context_menus/users.html.erb @@ -25,6 +25,10 @@