2017-02-16 12:28:10 +11:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Admin::ReportsController < ApplicationController
|
|
|
|
before_action :require_admin!
|
2017-02-17 10:42:52 +11:00
|
|
|
before_action :set_report, except: [:index]
|
2017-02-16 12:28:10 +11:00
|
|
|
|
|
|
|
layout 'admin'
|
|
|
|
|
|
|
|
def index
|
2017-04-03 00:45:49 +10:00
|
|
|
@reports = Report.includes(:account, :target_account).order('id desc').paginate(page: params[:page], per_page: 40)
|
2017-02-16 12:28:10 +11:00
|
|
|
@reports = params[:action_taken].present? ? @reports.resolved : @reports.unresolved
|
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
@statuses = Status.where(id: @report.status_ids)
|
|
|
|
end
|
2017-02-17 10:42:52 +11:00
|
|
|
|
|
|
|
def resolve
|
2017-04-04 03:27:30 +10:00
|
|
|
@report.update(action_taken: true, action_taken_by_account_id: current_account.id)
|
2017-02-17 10:42:52 +11:00
|
|
|
redirect_to admin_report_path(@report)
|
|
|
|
end
|
|
|
|
|
|
|
|
def suspend
|
|
|
|
Admin::SuspensionWorker.perform_async(@report.target_account.id)
|
2017-04-04 03:27:30 +10:00
|
|
|
Report.unresolved.where(target_account: @report.target_account).update_all(action_taken: true, action_taken_by_account_id: current_account.id)
|
2017-02-17 10:42:52 +11:00
|
|
|
redirect_to admin_report_path(@report)
|
|
|
|
end
|
|
|
|
|
|
|
|
def silence
|
|
|
|
@report.target_account.update(silenced: true)
|
2017-04-04 03:27:30 +10:00
|
|
|
Report.unresolved.where(target_account: @report.target_account).update_all(action_taken: true, action_taken_by_account_id: current_account.id)
|
2017-02-17 10:42:52 +11:00
|
|
|
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 12:28:10 +11:00
|
|
|
end
|