From 3719a6cfd793d38f3794769b3e2cec4eac196ae4 Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Sat, 23 Jan 2021 01:41:35 -0500 Subject: [PATCH] Added checks to suspension to for pro, verified, donor, investor accounts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Added: - checks to suspension to for pro, verified, donor, investor accounts --- app/policies/account_policy.rb | 2 +- app/services/suspend_account_service.rb | 1 + app/views/admin/reports/show.html.haml | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/policies/account_policy.rb b/app/policies/account_policy.rb index 7e95367f..d17a513d 100644 --- a/app/policies/account_policy.rb +++ b/app/policies/account_policy.rb @@ -14,7 +14,7 @@ class AccountPolicy < ApplicationPolicy end def suspend? - staff? && !record.user&.staff? + staff? && !record.user&.staff? && !record.is_pro? && !record.is_investor? && !record.is_donor? && !record.is_verified? end def unsuspend? diff --git a/app/services/suspend_account_service.rb b/app/services/suspend_account_service.rb index 3b5c1031..d2e78387 100644 --- a/app/services/suspend_account_service.rb +++ b/app/services/suspend_account_service.rb @@ -45,6 +45,7 @@ class SuspendAccountService < BaseService # @option [Boolean] :destroy Remove the account record instead of suspending def call(account, **options) @account = account + return true if @account.is_pro? || @account.is_verified? || @account.is_donor? || @account.is_investor? @options = options purge_user! diff --git a/app/views/admin/reports/show.html.haml b/app/views/admin/reports/show.html.haml index 863dada9..a512f970 100644 --- a/app/views/admin/reports/show.html.haml +++ b/app/views/admin/reports/show.html.haml @@ -11,7 +11,8 @@ = link_to t('admin.accounts.warn'), new_admin_account_action_path(@report.target_account_id, type: 'none', report_id: @report.id), class: 'button' = link_to t('admin.accounts.disable'), new_admin_account_action_path(@report.target_account_id, type: 'disable', report_id: @report.id), class: 'button button--destructive' = link_to t('admin.accounts.silence'), new_admin_account_action_path(@report.target_account_id, type: 'silence', report_id: @report.id), class: 'button button--destructive' - = link_to t('admin.accounts.perform_full_suspension'), new_admin_account_action_path(@report.target_account_id, type: 'suspend', report_id: @report.id), class: 'button button--destructive' + - if !@report.target_account.is_pro? && !@report.target_account.is_investor? && !@report.target_account.is_donor? && !@report.target_account.is_verified? + = link_to t('admin.accounts.perform_full_suspension'), new_admin_account_action_path(@report.target_account_id, type: 'suspend', report_id: @report.id), class: 'button button--destructive' %div{ style: 'float: left' } = link_to t('admin.reports.mark_as_resolved'), resolve_admin_report_path(@report), method: :post, class: 'button' - else