Hide importing accounts
This commit is contained in:
@@ -2,6 +2,7 @@ class Account::ImportsController < ApplicationController
|
||||
layout "public"
|
||||
|
||||
disallow_account_scope only: %i[ new create ]
|
||||
allow_unauthorized_access only: :show
|
||||
before_action :set_import, only: %i[ show ]
|
||||
|
||||
def new
|
||||
|
||||
@@ -12,6 +12,9 @@ class Account < ApplicationRecord
|
||||
has_many :exports, class_name: "Account::Export", dependent: :destroy
|
||||
has_many :imports, class_name: "Account::Import", dependent: :destroy
|
||||
|
||||
scope :importing, -> { left_joins(:imports).where(account_imports: { status: %i[pending processing failed] }) }
|
||||
scope :active, -> { where.missing(:cancellation).and(where.not(id: importing)) }
|
||||
|
||||
before_create :assign_external_account_id
|
||||
after_create :create_join_code
|
||||
|
||||
@@ -38,6 +41,14 @@ class Account < ApplicationRecord
|
||||
users.find_by!(role: :system)
|
||||
end
|
||||
|
||||
def active?
|
||||
!cancelled? && !importing?
|
||||
end
|
||||
|
||||
def importing?
|
||||
imports.where(status: %i[pending processing failed]).exists?
|
||||
end
|
||||
|
||||
private
|
||||
def assign_external_account_id
|
||||
self.external_account_id ||= ExternalIdSequence.next
|
||||
|
||||
@@ -4,8 +4,6 @@ module Account::Cancellable
|
||||
included do
|
||||
has_one :cancellation, dependent: :destroy
|
||||
|
||||
scope :active, -> { where.missing(:cancellation) }
|
||||
|
||||
define_callbacks :cancel
|
||||
define_callbacks :reactivate
|
||||
end
|
||||
@@ -32,10 +30,6 @@ module Account::Cancellable
|
||||
end
|
||||
end
|
||||
|
||||
def active?
|
||||
!cancelled?
|
||||
end
|
||||
|
||||
def cancelled?
|
||||
cancellation.present?
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user