Fix batch actions not working on pending accounts (#10508)

This commit is contained in:
ThibG 2019-04-08 18:35:41 +02:00 committed by Eugen Rochko
parent 3f036ac6b8
commit 5247ea4efd
4 changed files with 6 additions and 4 deletions

View File

@ -8,11 +8,11 @@ module Admin
@form = Form::AccountBatch.new @form = Form::AccountBatch.new
end end
def update def batch
@form = Form::AccountBatch.new(form_account_batch_params.merge(current_account: current_account, action: action_from_button)) @form = Form::AccountBatch.new(form_account_batch_params.merge(current_account: current_account, action: action_from_button))
@form.save @form.save
rescue ActionController::ParameterMissing rescue ActionController::ParameterMissing
# Do nothing flash[:alert] = I18n.t('admin.accounts.no_account_selected')
ensure ensure
redirect_to admin_pending_accounts_path(current_params) redirect_to admin_pending_accounts_path(current_params)
end end

View File

@ -4,7 +4,7 @@
- content_for :header_tags do - content_for :header_tags do
= javascript_pack_tag 'admin', integrity: true, async: true, crossorigin: 'anonymous' = javascript_pack_tag 'admin', integrity: true, async: true, crossorigin: 'anonymous'
= form_for(@form, url: admin_pending_accounts_path, method: :patch) do |f| = form_for(@form, url: batch_admin_pending_accounts_path) do |f|
= hidden_field_tag :page, params[:page] || 1 = hidden_field_tag :page, params[:page] || 1
.batch-table .batch-table

View File

@ -134,6 +134,7 @@ en:
moderation_notes: Moderation notes moderation_notes: Moderation notes
most_recent_activity: Most recent activity most_recent_activity: Most recent activity
most_recent_ip: Most recent IP most_recent_ip: Most recent IP
no_account_selected: No accounts were changed as none were selected
no_limits_imposed: No limits imposed no_limits_imposed: No limits imposed
not_subscribed: Not subscribed not_subscribed: Not subscribed
outbox_url: Outbox URL outbox_url: Outbox URL

View File

@ -214,10 +214,11 @@ Rails.application.routes.draw do
end end
end end
resources :pending_accounts, only: [:index, :update] do resources :pending_accounts, only: [:index] do
collection do collection do
post :approve_all post :approve_all
post :reject_all post :reject_all
post :batch
end end
end end