From 6322650728c8c642ee370f45c4f118896fd6f0c8 Mon Sep 17 00:00:00 2001 From: Marius Balteanu Date: Sat, 13 Jul 2024 10:21:49 +0000 Subject: Add bulk unlock to user list context menu (#40913). git-svn-id: https://svn.redmine.org/redmine/trunk@22925 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/users_controller.rb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'app/controllers') 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 -- cgit v1.2.3