You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.0 KiB

  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