Feature #40913 » 0001-Add-bulk-unlock-users-action.patch
| app/controllers/users_controller.rb | ||
|---|---|---|
|
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
|
||
| ... | ... | |
|
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
|
||
| app/views/context_menus/users.html.erb | ||
|---|---|---|
|
<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),
|
||
| config/routes.rb | ||
|---|---|---|
|
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]
|
||
- « Previous
- 1
- 2
- 3
- Next »