Hide importing accounts

This commit is contained in:
Stanko K.R.
2026-01-30 16:25:01 +01:00
parent 27c73ff42b
commit a791fe1919
3 changed files with 12 additions and 6 deletions
@@ -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
+11
View File
@@ -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
-6
View File
@@ -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