Sha256: de446bb6e7f023dcdd27a9ed0de182bb3efd7e81266d47f6492c90ae45280b54

Contents?: true

Size: 953 Bytes

Versions: 9

Compression:

Stored size: 953 Bytes

Contents

module Katello
  class SystemHostCollection < Katello::Model
    self.include_root_in_json = false

    belongs_to :system, :inverse_of => :system_host_collections, :class_name => 'Katello::System'
    belongs_to :host_collection, :inverse_of => :system_host_collections

    validate :validate_max_content_hosts_not_exceeded

    def validate_max_content_hosts_not_exceeded
      if new_record?
        host_collection = HostCollection.find(self.host_collection_id)
        if (host_collection) && (!host_collection.unlimited_content_hosts) && (host_collection.systems.size >= host_collection.max_content_hosts)
          errors.add :base,
                     _("You cannot have more than %{max_content_hosts} content host(s) associated with host collection '%{host_collection}'.") %
                         { :max_content_hosts => host_collection.max_content_hosts, :host_collection => host_collection.name }
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
katello-2.4.5 app/models/katello/system_host_collection.rb
katello-2.4.4 app/models/katello/system_host_collection.rb
katello-2.4.3 app/models/katello/system_host_collection.rb
katello-2.4.2 app/models/katello/system_host_collection.rb
katello-2.4.1 app/models/katello/system_host_collection.rb
katello-2.4.0 app/models/katello/system_host_collection.rb
katello-2.4.0.rc3 app/models/katello/system_host_collection.rb
katello-2.4.0.rc2 app/models/katello/system_host_collection.rb
katello-2.4.0.rc1 app/models/katello/system_host_collection.rb