about summary refs log tree commit diff
path: root/app/controllers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-12-04 18:10:40 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-12-04 18:10:40 +0100
commit9d9f796130407c6dc68118949537235faf25fcb9 (patch)
tree087b899593aa034880d806321c7c119cca9a2676 /app/controllers
parentd236dcded20b1a561b1f396fbb423811f27c77e5 (diff)
Adding more to admin accounts UI
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/admin/accounts_controller.rb25
1 files changed, 24 insertions, 1 deletions
diff --git a/app/controllers/admin/accounts_controller.rb b/app/controllers/admin/accounts_controller.rb
index 92ebffc87..79fb37eb9 100644
--- a/app/controllers/admin/accounts_controller.rb
+++ b/app/controllers/admin/accounts_controller.rb
@@ -2,14 +2,37 @@
 
 class Admin::AccountsController < ApplicationController
   before_action :require_admin!
+  before_action :set_account, except: :index
 
   layout 'public'
 
   def index
     @accounts = Account.order('domain ASC, username ASC').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.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
   end
 
-  def show
+  private
+
+  def set_account
     @account = Account.find(params[:id])
   end
+
+  def account_params
+    params.require(:account).permit(:silenced)
+  end
 end