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.

55 lines
1.5 KiB

  1. # frozen_string_literal: true
  2. module Admin
  3. class ReportNotesController < BaseController
  4. before_action :set_report_note, only: [:destroy]
  5. def create
  6. authorize :report_note, :create?
  7. @report_note = current_account.report_notes.new(resource_params)
  8. @report = @report_note.report
  9. if @report_note.save
  10. if params[:create_and_resolve]
  11. @report.resolve!(current_account)
  12. log_action :resolve, @report
  13. redirect_to admin_reports_path, notice: I18n.t('admin.reports.resolved_msg')
  14. return
  15. end
  16. if params[:create_and_unresolve]
  17. @report.unresolve!
  18. log_action :reopen, @report
  19. end
  20. redirect_to admin_report_path(@report), notice: I18n.t('admin.report_notes.created_msg')
  21. else
  22. @report_notes = (@report.notes.latest + @report.history + @report.target_account.targeted_account_warnings.latest.custom).sort_by(&:created_at)
  23. @form = Form::StatusBatch.new
  24. render template: 'admin/reports/show'
  25. end
  26. end
  27. def destroy
  28. authorize @report_note, :destroy?
  29. @report_note.destroy!
  30. redirect_to admin_report_path(@report_note.report_id), notice: I18n.t('admin.report_notes.destroyed_msg')
  31. end
  32. private
  33. def resource_params
  34. params.require(:report_note).permit(
  35. :content,
  36. :report_id
  37. )
  38. end
  39. def set_report_note
  40. @report_note = ReportNote.find(params[:id])
  41. end
  42. end
  43. end