2017-02-16 01:28:10 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-10 20:27:03 +01:00
|
|
|
module Admin
|
|
|
|
class ReportsController < BaseController
|
|
|
|
before_action :set_report, except: [:index]
|
|
|
|
|
|
|
|
def index
|
2017-04-11 00:11:41 +01:00
|
|
|
@reports = Report.includes(:account, :target_account).order('id desc').page(params[:page])
|
2017-04-10 20:27:03 +01:00
|
|
|
@reports = params[:action_taken].present? ? @reports.resolved : @reports.unresolved
|
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
@statuses = Status.where(id: @report.status_ids)
|
|
|
|
end
|
|
|
|
|
|
|
|
def resolve
|
|
|
|
@report.update(action_taken: true, action_taken_by_account_id: current_account.id)
|
|
|
|
redirect_to admin_report_path(@report)
|
|
|
|
end
|
|
|
|
|
|
|
|
def suspend
|
|
|
|
Admin::SuspensionWorker.perform_async(@report.target_account.id)
|
|
|
|
Report.unresolved.where(target_account: @report.target_account).update_all(action_taken: true, action_taken_by_account_id: current_account.id)
|
|
|
|
redirect_to admin_report_path(@report)
|
|
|
|
end
|
|
|
|
|
|
|
|
def silence
|
|
|
|
@report.target_account.update(silenced: true)
|
|
|
|
Report.unresolved.where(target_account: @report.target_account).update_all(action_taken: true, action_taken_by_account_id: current_account.id)
|
|
|
|
redirect_to admin_report_path(@report)
|
|
|
|
end
|
|
|
|
|
|
|
|
def remove
|
|
|
|
RemovalWorker.perform_async(params[:status_id])
|
|
|
|
redirect_to admin_report_path(@report)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_report
|
|
|
|
@report = Report.find(params[:id])
|
|
|
|
end
|
2017-02-16 23:42:52 +00:00
|
|
|
end
|
2017-02-16 01:28:10 +00:00
|
|
|
end
|