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.2.0.rc1 app/models/katello/host_collection_hosts.rb
katello-4.0.2.1 app/models/katello/host_collection_hosts.rb
katello-4.1.2.1 app/models/katello/host_collection_hosts.rb
katello-4.0.2 app/models/katello/host_collection_hosts.rb
katello-4.1.2 app/models/katello/host_collection_hosts.rb
katello-3.18.4 app/models/katello/host_collection_hosts.rb
katello-4.1.1 app/models/katello/host_collection_hosts.rb
katello-4.1.0 app/models/katello/host_collection_hosts.rb
katello-4.0.1.2 app/models/katello/host_collection_hosts.rb
katello-3.18.3.1 app/models/katello/host_collection_hosts.rb
katello-4.1.0.rc2.2 app/models/katello/host_collection_hosts.rb
katello-4.1.0.rc2.1 app/models/katello/host_collection_hosts.rb
katello-4.0.1.1 app/models/katello/host_collection_hosts.rb
katello-3.18.3 app/models/katello/host_collection_hosts.rb
katello-4.1.0.rc2 app/models/katello/host_collection_hosts.rb
katello-4.0.1 app/models/katello/host_collection_hosts.rb
katello-4.1.0.rc1.1 app/models/katello/host_collection_hosts.rb
katello-4.1.0.rc1 app/models/katello/host_collection_hosts.rb
katello-4.0.0 app/models/katello/host_collection_hosts.rb
katello-4.0.0.rc3.1 app/models/katello/host_collection_hosts.rb