Sha256: 2683b52aa1c32dc9a364964c6b9ab2cc03aedf1e26f824c51a5a4ef19220b3cd

Contents?: true

Size: 904 Bytes

Versions: 189

Compression:

Stored size: 904 Bytes

Contents

module Katello
  class HostCollectionHosts < Katello::Model
    belongs_to :host, :inverse_of => :host_collection_hosts, :class_name => 'Host::Managed'
    belongs_to :host_collection, :inverse_of => :host_collection_hosts, :class_name => "Katello::HostCollection"

    validate :validate_max_hosts_not_exceeded

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

Version data entries

189 entries across 189 versions & 1 rubygems

Version Path
katello-4.15.0.rc2 app/models/katello/host_collection_hosts.rb
katello-4.15.0.rc1 app/models/katello/host_collection_hosts.rb
katello-4.14.1 app/models/katello/host_collection_hosts.rb
katello-4.14.0 app/models/katello/host_collection_hosts.rb
katello-4.14.0.rc3 app/models/katello/host_collection_hosts.rb
katello-4.14.0.rc2 app/models/katello/host_collection_hosts.rb
katello-4.14.0.rc1.1 app/models/katello/host_collection_hosts.rb
katello-4.14.0.rc1 app/models/katello/host_collection_hosts.rb
katello-4.13.1 app/models/katello/host_collection_hosts.rb
katello-4.13.0 app/models/katello/host_collection_hosts.rb
katello-4.12.1 app/models/katello/host_collection_hosts.rb
katello-4.13.0.rc1 app/models/katello/host_collection_hosts.rb
katello-4.12.0 app/models/katello/host_collection_hosts.rb
katello-4.12.0.rc3 app/models/katello/host_collection_hosts.rb
katello-4.12.0.rc2 app/models/katello/host_collection_hosts.rb
katello-4.12.0.rc1 app/models/katello/host_collection_hosts.rb
katello-4.11.1 app/models/katello/host_collection_hosts.rb
katello-4.11.0 app/models/katello/host_collection_hosts.rb
katello-4.11.0.rc2 app/models/katello/host_collection_hosts.rb
katello-4.11.0.rc1 app/models/katello/host_collection_hosts.rb