1
0
مراية لـ https://github.com/postalserver/postal.git تم المزامنة 2025-12-01 05:43:04 +00:00

remove types from ip pools

closes #24
هذا الالتزام موجود في:
Adam Cooke
2017-04-28 16:40:53 +01:00
الأصل 88974cee85
التزام 698b580db4
10 ملفات معدلة مع 14 إضافات و29 حذوفات

عرض الملف

@@ -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