Admin base controller (#1465)
* Add Admin::BaseController to wrap admin area Extracts the setting of the `admin` layout and verifying that users are admins to a common base class for the admin/ controllers. * Add basic coverage for admin/reports and admin/settings controllers
This commit is contained in:
parent
1be6aa0c7f
commit
dbe9f33fdc
8 changed files with 154 additions and 125 deletions
|
@ -1,45 +1,44 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Admin::ReportsController < ApplicationController
|
||||
before_action :require_admin!
|
||||
before_action :set_report, except: [:index]
|
||||
module Admin
|
||||
class ReportsController < BaseController
|
||||
before_action :set_report, except: [:index]
|
||||
|
||||
layout 'admin'
|
||||
def index
|
||||
@reports = Report.includes(:account, :target_account).order('id desc').paginate(page: params[:page], per_page: 40)
|
||||
@reports = params[:action_taken].present? ? @reports.resolved : @reports.unresolved
|
||||
end
|
||||
|
||||
def index
|
||||
@reports = Report.includes(:account, :target_account).order('id desc').paginate(page: params[:page], per_page: 40)
|
||||
@reports = params[:action_taken].present? ? @reports.resolved : @reports.unresolved
|
||||
end
|
||||
def show
|
||||
@statuses = Status.where(id: @report.status_ids)
|
||||
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 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 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 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
|
||||
|
||||
def remove
|
||||
RemovalWorker.perform_async(params[:status_id])
|
||||
redirect_to admin_report_path(@report)
|
||||
end
|
||||
private
|
||||
|
||||
private
|
||||
|
||||
def set_report
|
||||
@report = Report.find(params[:id])
|
||||
def set_report
|
||||
@report = Report.find(params[:id])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue