reported_statuses_controller.rb 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # frozen_string_literal: true
  2. module Admin
  3. class ReportedStatusesController < BaseController
  4. include Authorization
  5. before_action :set_report
  6. before_action :set_status, only: [:update, :destroy]
  7. def create
  8. @form = Form::StatusBatch.new(form_status_batch_params)
  9. flash[:alert] = t('admin.statuses.failed_to_execute') unless @form.save
  10. redirect_to admin_report_path(@report)
  11. end
  12. def update
  13. @status.update(status_params)
  14. redirect_to admin_report_path(@report)
  15. end
  16. def destroy
  17. authorize @status, :destroy?
  18. RemovalWorker.perform_async(@status.id)
  19. render json: @status
  20. end
  21. private
  22. def status_params
  23. params.require(:status).permit(:sensitive)
  24. end
  25. def form_status_batch_params
  26. params.require(:form_status_batch).permit(:action, status_ids: [])
  27. end
  28. def set_report
  29. @report = Report.find(params[:report_id])
  30. end
  31. def set_status
  32. @status = @report.statuses.find(params[:id])
  33. end
  34. end
  35. end