1
0

account_actions_controller.rb 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # frozen_string_literal: true
  2. module Admin
  3. class AccountActionsController < BaseController
  4. before_action :set_account
  5. def new
  6. authorize @account, :show?
  7. @account_action = Admin::AccountAction.new(type: params[:type], report_id: params[:report_id], send_email_notification: true, include_statuses: true)
  8. @warning_presets = AccountWarningPreset.all
  9. end
  10. def create
  11. authorize @account, :show?
  12. account_action = Admin::AccountAction.new(resource_params)
  13. account_action.target_account = @account
  14. account_action.current_account = current_account
  15. account_action.save!
  16. if account_action.with_report?
  17. redirect_to admin_reports_path, notice: I18n.t('admin.reports.processed_msg', id: resource_params[:report_id])
  18. else
  19. redirect_to admin_account_path(@account.id)
  20. end
  21. end
  22. private
  23. def set_account
  24. @account = Account.find(params[:account_id])
  25. end
  26. def resource_params
  27. params.require(:admin_account_action).permit(:type, :report_id, :warning_preset_id, :text, :send_email_notification, :include_statuses)
  28. end
  29. end
  30. end