mirror of
https://github.com/meineerde/redmine.git
synced 2026-01-31 19:47:14 +00:00
Add bulk unlock to user list context menu (#40913).
git-svn-id: https://svn.redmine.org/redmine/trunk@22925 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
20dcd39f42
commit
6322650728
@ -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
|
||||
|
||||
@ -25,6 +25,10 @@
|
||||
<li>
|
||||
<%= context_menu_link l(:button_lock), bulk_lock_users_path(ids: @users.map(&:id)), method: :post, class: 'icon icon-lock' %>
|
||||
</li>
|
||||
<% else %>
|
||||
<li>
|
||||
<%= context_menu_link l(:button_unlock), bulk_unlock_users_path(ids: @users.map(&:id)), method: :post, class: 'icon icon-unlock' %>
|
||||
</li>
|
||||
<% end %>
|
||||
<li>
|
||||
<%= context_menu_link l(:button_delete),
|
||||
|
||||
@ -113,6 +113,7 @@ Rails.application.routes.draw do
|
||||
collection do
|
||||
delete 'bulk_destroy'
|
||||
post :bulk_lock
|
||||
post :bulk_unlock
|
||||
end
|
||||
resources :memberships, :controller => 'principal_memberships'
|
||||
resources :email_addresses, :only => [:index, :create, :update, :destroy]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user