Fix admin UI for accounts somewhat

lolsob-rspec
Eugen Rochko 2017-02-15 00:22:58 +01:00
parent 596de038c8
commit 513a78d67b
5 changed files with 58 additions and 31 deletions

View File

@ -76,6 +76,7 @@
.content-wrapper { .content-wrapper {
flex: 2; flex: 2;
overflow: auto;
} }
.content { .content {

View File

@ -19,19 +19,26 @@ class Admin::AccountsController < ApplicationController
def show; end def show; end
def update
if @account.update(account_params)
redirect_to admin_accounts_path
else
render :show
end
end
def suspend def suspend
Admin::SuspensionWorker.perform_async(@account.id) Admin::SuspensionWorker.perform_async(@account.id)
redirect_to admin_accounts_path redirect_to admin_accounts_path
end 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 unsilence
@account.update(silenced: false)
redirect_to admin_accounts_path
end
private private
def set_account def set_account

View File

@ -25,9 +25,7 @@
%tr %tr
%th Username %th Username
%th Domain %th Domain
%th Subscribed %th= fa_icon 'paper-plane-o'
%th Silenced
%th Suspended
%th %th
%tbody %tbody
- @accounts.each do |account| - @accounts.each do |account|
@ -43,16 +41,6 @@
%i.fa.fa-check %i.fa.fa-check
- else - else
%i.fa.fa-times %i.fa.fa-times
%td
- if account.silenced?
%i.fa.fa-check
- else
%i.fa.fa-times
%td
- if account.suspended?
%i.fa.fa-check
- else
%i.fa.fa-times
%td %td
= table_link_to 'circle', 'Web', web_path("accounts/#{account.id}") = table_link_to 'circle', 'Web', web_path("accounts/#{account.id}")
= table_link_to 'globe', 'Public', TagManager.instance.url_for(account) = table_link_to 'globe', 'Public', TagManager.instance.url_for(account)

View File

@ -18,8 +18,11 @@
%th E-mail %th E-mail
%td= @account.user.email %td= @account.user.email
%tr %tr
%th Current IP %th Most recent IP
%td= @account.user.current_sign_in_ip %td= @account.user.current_sign_in_ip
%tr
%th Most recent activity
%td= l @account.user.current_sign_in_at
- else - else
%tr %tr
%th Profile URL %th Profile URL
@ -27,14 +30,39 @@
%tr %tr
%th Feed URL %th Feed URL
%td= link_to @account.remote_url %td= link_to @account.remote_url
%tr
%th PuSH subscription expires
%td
- if @account.subscribed?
= l @account.subscription_expires_at
- else
Not subscribed
%tr
%th Salmon URL
%td= link_to @account.salmon_url
= simple_form_for @account, url: admin_account_path(@account.id) do |f| %tr
= render 'shared/error_messages', object: @account %th Follows
%td= @account.following.count
%tr
%th Followers
%td= @account.followers.count
%tr
%th Statuses
%td= @account.statuses.count
%tr
%th Media attachments
%td
= @account.media_attachments.count
= surround '(', ')' do
= number_to_human_size @account.media_attachments.sum('file_file_size')
= f.input :silenced, as: :boolean, wrapper: :with_label - if @account.silenced?
= f.input :suspended, as: :boolean, wrapper: :with_label = link_to 'Undo silence', unsilence_admin_account_path(@account.id), method: :post, class: 'button'
- else
= link_to 'Silence', silence_admin_account_path(@account.id), method: :post, class: 'button'
.actions - if @account.suspended?
= f.button :button, t('generic.save_changes'), type: :submit = link_to 'Undo suspension', unsuspend_admin_account_path(@account.id), method: :post, class: 'button'
- else
= link_to 'Perform full suspension', suspend_admin_account_path(@account.id), method: :post, data: { confirm: 'Are you sure?' }, class: 'button' = link_to 'Perform full suspension', suspend_admin_account_path(@account.id), method: :post, data: { confirm: 'Are you sure?' }, class: 'button'

View File

@ -67,9 +67,12 @@ Rails.application.routes.draw do
resources :domain_blocks, only: [:index, :create] resources :domain_blocks, only: [:index, :create]
resources :settings, only: [:index, :update] resources :settings, only: [:index, :update]
resources :accounts, only: [:index, :show, :update] do resources :accounts, only: [:index, :show] do
member do member do
post :silence
post :unsilence
post :suspend post :suspend
post :unsuspend
end end
end end
end end