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,51 +1,50 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Admin::AccountsController < ApplicationController
|
||||
before_action :require_admin!
|
||||
before_action :set_account, except: :index
|
||||
module Admin
|
||||
class AccountsController < BaseController
|
||||
before_action :set_account, except: :index
|
||||
|
||||
layout 'admin'
|
||||
def index
|
||||
@accounts = Account.alphabetic.paginate(page: params[:page], per_page: 40)
|
||||
|
||||
def index
|
||||
@accounts = Account.alphabetic.paginate(page: params[:page], per_page: 40)
|
||||
@accounts = @accounts.local if params[:local].present?
|
||||
@accounts = @accounts.remote if params[:remote].present?
|
||||
@accounts = @accounts.where(domain: params[:by_domain]) if params[:by_domain].present?
|
||||
@accounts = @accounts.silenced if params[:silenced].present?
|
||||
@accounts = @accounts.recent if params[:recent].present?
|
||||
@accounts = @accounts.suspended if params[:suspended].present?
|
||||
end
|
||||
|
||||
@accounts = @accounts.local if params[:local].present?
|
||||
@accounts = @accounts.remote if params[:remote].present?
|
||||
@accounts = @accounts.where(domain: params[:by_domain]) if params[:by_domain].present?
|
||||
@accounts = @accounts.silenced if params[:silenced].present?
|
||||
@accounts = @accounts.recent if params[:recent].present?
|
||||
@accounts = @accounts.suspended if params[:suspended].present?
|
||||
end
|
||||
def show; end
|
||||
|
||||
def show; end
|
||||
def suspend
|
||||
Admin::SuspensionWorker.perform_async(@account.id)
|
||||
redirect_to admin_accounts_path
|
||||
end
|
||||
|
||||
def suspend
|
||||
Admin::SuspensionWorker.perform_async(@account.id)
|
||||
redirect_to admin_accounts_path
|
||||
end
|
||||
def unsuspend
|
||||
@account.update(suspended: false)
|
||||
redirect_to admin_accounts_path
|
||||
end
|
||||
|
||||
def unsuspend
|
||||
@account.update(suspended: false)
|
||||
redirect_to admin_accounts_path
|
||||
end
|
||||
def silence
|
||||
@account.update(silenced: true)
|
||||
redirect_to admin_accounts_path
|
||||
end
|
||||
|
||||
def silence
|
||||
@account.update(silenced: true)
|
||||
redirect_to admin_accounts_path
|
||||
end
|
||||
def unsilence
|
||||
@account.update(silenced: false)
|
||||
redirect_to admin_accounts_path
|
||||
end
|
||||
|
||||
def unsilence
|
||||
@account.update(silenced: false)
|
||||
redirect_to admin_accounts_path
|
||||
end
|
||||
private
|
||||
|
||||
private
|
||||
def set_account
|
||||
@account = Account.find(params[:id])
|
||||
end
|
||||
|
||||
def set_account
|
||||
@account = Account.find(params[:id])
|
||||
end
|
||||
|
||||
def account_params
|
||||
params.require(:account).permit(:silenced, :suspended)
|
||||
def account_params
|
||||
params.require(:account).permit(:silenced, :suspended)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue