مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2025-12-01 05:43:04 +00:00
@@ -8,7 +8,6 @@
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# default :boolean default(FALSE)
|
||||
# type :string(255)
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
@@ -17,8 +16,6 @@
|
||||
|
||||
class IPPool < ApplicationRecord
|
||||
|
||||
TYPES = ['Transactional', 'Bulk', 'Forwarding', 'Dedicated']
|
||||
|
||||
include HasUUID
|
||||
|
||||
validates :name, :presence => true
|
||||
@@ -28,21 +25,8 @@ class IPPool < ApplicationRecord
|
||||
has_many :organization_ip_pools, :dependent => :destroy
|
||||
has_many :organizations, :through => :organization_ip_pools
|
||||
|
||||
scope :transactional, -> { where(:type => 'Transactional') }
|
||||
scope :bulk, -> { where(:type => 'Bulk') }
|
||||
scope :forwarding, -> { where(:type => 'Forwarding') }
|
||||
scope :dedicated, -> { where(:type => 'Dedicated') }
|
||||
|
||||
def self.default
|
||||
where(:default => true).order(:id).first
|
||||
end
|
||||
|
||||
def description
|
||||
desc = "#{name}"
|
||||
if self.type == 'Dedicated'
|
||||
desc += " (#{ip_addresses.map(&:ipv4).to_sentence})"
|
||||
end
|
||||
desc
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -48,8 +48,8 @@ class Organization < ApplicationRecord
|
||||
has_many :ip_pool_rules, :dependent => :destroy, :as => :owner
|
||||
|
||||
after_create do
|
||||
if pool = IPPool.transactional.default
|
||||
self.ip_pools << IPPool.transactional.default
|
||||
if pool = IPPool.default
|
||||
self.ip_pools << IPPool.default
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم