2016-11-30 09:32:26 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Admin::AccountsController < ApplicationController
|
|
|
|
before_action :require_admin!
|
2016-12-04 12:10:40 -05:00
|
|
|
before_action :set_account, except: :index
|
2016-11-30 09:32:26 -05:00
|
|
|
|
|
|
|
layout 'public'
|
|
|
|
|
|
|
|
def index
|
2016-12-03 13:08:07 -05:00
|
|
|
@accounts = Account.order('domain ASC, username ASC').paginate(page: params[:page], per_page: 40)
|
2016-12-04 12:10:40 -05:00
|
|
|
|
|
|
|
@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.where(silenced: true) if params[:silenced].present?
|
|
|
|
@accounts = @accounts.reorder('id desc') if params[:recent].present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def show; end
|
|
|
|
|
|
|
|
def update
|
|
|
|
if @account.update(account_params)
|
|
|
|
redirect_to admin_accounts_path
|
|
|
|
else
|
|
|
|
render :show
|
|
|
|
end
|
2016-11-30 09:32:26 -05:00
|
|
|
end
|
|
|
|
|
2016-12-04 12:10:40 -05:00
|
|
|
private
|
|
|
|
|
|
|
|
def set_account
|
2016-12-03 13:08:07 -05:00
|
|
|
@account = Account.find(params[:id])
|
2016-11-30 09:32:26 -05:00
|
|
|
end
|
2016-12-04 12:10:40 -05:00
|
|
|
|
|
|
|
def account_params
|
|
|
|
params.require(:account).permit(:silenced)
|
|
|
|
end
|
2016-11-30 09:32:26 -05:00
|
|
|
end
|