Skip to content

Commit

Permalink
各アカウントの画面を調整
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode committed Feb 17, 2024
1 parent bc4dca9 commit 25808df
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 5 deletions.
16 changes: 15 additions & 1 deletion app/controllers/admin/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Admin
class AccountsController < BaseController
before_action :set_account, except: [:index, :batch]
before_action :require_remote_account!, only: [:redownload]
before_action :require_remote_account!, only: [:redownload, :approve_remote, :reject_remote]
before_action :require_local_account!, only: [:enable, :memorialize, :approve, :reject]

def index
Expand Down Expand Up @@ -66,6 +66,20 @@ def reject
redirect_to admin_accounts_path(status: 'pending'), notice: I18n.t('admin.accounts.rejected_msg', username: @account.acct)
end

def approve_remote
authorize @account, :approve_remote?
@account.approve_remote!
log_action :approve_remote, @account
redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.approved_msg', username: @account.acct)
end

def reject_remote
authorize @account, :reject_remote?
@account.reject_remote!
log_action :reject_remote, @account
redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.rejected_msg', username: @account.acct)
end

def destroy
authorize @account, :destroy?
Admin::AccountDeletionWorker.perform_async(@account.id)
Expand Down
3 changes: 1 addition & 2 deletions app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,7 @@ def approve_remote!
end

def reject_remote!
update!(remote_pending: false)
suspend!
update!(remote_pending: false, suspension_origin: :local)
end

def sensitized?
Expand Down
9 changes: 7 additions & 2 deletions app/views/admin/accounts/_buttons.html.haml
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
- if account.suspended?
- if account.suspended? && !account.remote_pending
%hr.spacer/
- if account.suspension_origin_remote?
%p.muted-hint= deletion_request.present? ? t('admin.accounts.remote_suspension_reversible_hint_html', date: content_tag(:strong, l(deletion_request.due_at.to_date))) : t('admin.accounts.remote_suspension_irreversible')
- else
%p.muted-hint= deletion_request.present? ? t('admin.accounts.suspension_reversible_hint_html', date: content_tag(:strong, l(deletion_request.due_at.to_date))) : t('admin.accounts.suspension_irreversible')
= link_to t('admin.accounts.undo_suspension'), unsuspend_admin_account_path(account.id), method: :post, class: 'button' if can?(:unsuspend, account) && !account.remote_pending
= link_to t('admin.accounts.undo_suspension'), unsuspend_admin_account_path(account.id), method: :post, class: 'button' if can?(:unsuspend, account)
= link_to t('admin.accounts.redownload'), redownload_admin_account_path(account.id), method: :post, class: 'button' if can?(:redownload, account) && account.suspension_origin_remote?
- if deletion_request.present? && can?(:destroy, account)
= link_to t('admin.accounts.delete'), admin_account_path(account.id), method: :delete, class: 'button button--destructive', data: { confirm: t('admin.accounts.are_you_sure') }
- elsif account.suspended? && account.remote_pending
%hr.spacer/
%p.muted-hint= t('admin.accounts.remote_pending_hint_html')
= link_to t('admin.accounts.approve_remote'), approve_remote_admin_account_path(account.id), method: :post, class: 'button' if can?(:approve_remote, account)
= link_to t('admin.accounts.reject_remote'), reject_remote_admin_account_path(account.id), method: :post, class: 'button' if can?(:reject_remote, account)
- else
.action-buttons
%div
Expand Down
3 changes: 3 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ en:
add_email_domain_block: Block e-mail domain
approve: Approve
approve_domain: Approve domain
approve_remote: Approve remote account
approved_msg: Successfully approved %{username}'s sign-up application
are_you_sure: Are you sure?
avatar: Avatar
Expand Down Expand Up @@ -118,7 +119,9 @@ en:
redownload: Refresh profile
redownloaded_msg: Successfully refreshed %{username}'s profile from origin
reject: Reject
reject_remote: Reject remote account
rejected_msg: Successfully rejected %{username}'s sign-up application
remote_pending_hint_html: This account is currently on hold and temporarily suspended. The account must be approved before it can be made available on this server.
remote_suspension_irreversible: The data of this account has been irreversibly deleted.
remote_suspension_reversible_hint_html: The account has been suspended on their server, and the data will be fully removed on %{date}. Until then, the remote server can restore this account without any ill effects. If you wish to remove all of the account's data immediately, you can do so below.
remove_avatar: Remove avatar
Expand Down
3 changes: 3 additions & 0 deletions config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ ja:
add_email_domain_block: メールドメインブロックに追加
approve: 承認
approve_domain: ドメインを承認
approve_remote: リモートアカウントを承認
approved_msg: '%{username}さんの登録申請を承認しました'
are_you_sure: 本当に実行しますか?
avatar: アイコン
Expand Down Expand Up @@ -115,7 +116,9 @@ ja:
redownload: プロフィールを更新
redownloaded_msg: '%{username}のプロフィールを正常に更新しました'
reject: 却下
reject_remote: リモートアカウントを却下
rejected_msg: '%{username}さんの登録申請を却下しました'
remote_pending_hint_html: このアカウントは現在保留中で、一時的にサスペンド状態になっています。このサーバーで利用可能にするためには、アカウントを承認する必要があります。
remote_suspension_irreversible: このアカウントのデータは不可逆的に削除されました。
remote_suspension_reversible_hint_html: このアカウントは停止されており、データは%{date} 日で完全に削除されます。それまでは悪影響なしにアカウントを復旧させることができます。アカウントを即座に削除したい場合は、以下から行うことができます。
remove_avatar: アイコンを削除
Expand Down
2 changes: 2 additions & 0 deletions config/routes/admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@
post :memorialize
post :approve
post :reject
post :approve_remote
post :reject_remote
post :unblock_email
end

Expand Down

0 comments on commit 25808df

Please sign in to comment.