appeals_controller.rb 1020 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # frozen_string_literal: true
  2. class Admin::Disputes::AppealsController < Admin::BaseController
  3. before_action :set_appeal, except: :index
  4. def index
  5. authorize :appeal, :index?
  6. @appeals = filtered_appeals.page(params[:page])
  7. end
  8. def approve
  9. authorize @appeal, :approve?
  10. log_action :approve, @appeal
  11. ApproveAppealService.new.call(@appeal, current_account)
  12. redirect_to disputes_strike_path(@appeal.strike)
  13. end
  14. def reject
  15. authorize @appeal, :approve?
  16. log_action :reject, @appeal
  17. @appeal.reject!(current_account)
  18. UserMailer.appeal_rejected(@appeal.account.user, @appeal)
  19. redirect_to disputes_strike_path(@appeal.strike)
  20. end
  21. private
  22. def filtered_appeals
  23. Admin::AppealFilter.new(filter_params.with_defaults(status: 'pending')).results.includes(strike: :account)
  24. end
  25. def filter_params
  26. params.slice(:page, *Admin::AppealFilter::KEYS).permit(:page, *Admin::AppealFilter::KEYS)
  27. end
  28. def set_appeal
  29. @appeal = Appeal.find(params[:id])
  30. end
  31. end