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.

47 lines
1.1 KiB

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