Sha256: a3ea7e7c263d2bc7bc9c67e8f333180cd3f47b4896953982f238d0b15b62f8f9

Contents?: true

Size: 901 Bytes

Versions: 27

Compression:

Stored size: 901 Bytes

Contents

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

    belongs_to :host, :inverse_of => :host_collection_hosts, :class_name => 'Host::Managed'
    belongs_to :host_collection, :inverse_of => :host_collection_hosts

    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

27 entries across 27 versions & 1 rubygems

Version Path
katello-3.4.5 app/models/katello/host_collection_hosts.rb
katello-3.4.4 app/models/katello/host_collection_hosts.rb
katello-3.4.2 app/models/katello/host_collection_hosts.rb
katello-3.4.1 app/models/katello/host_collection_hosts.rb
katello-3.4.0.2 app/models/katello/host_collection_hosts.rb
katello-3.4.0.1 app/models/katello/host_collection_hosts.rb
katello-3.3.2 app/models/katello/host_collection_hosts.rb
katello-3.4.0 app/models/katello/host_collection_hosts.rb
katello-3.4.0.rc2 app/models/katello/host_collection_hosts.rb
katello-3.4.0.rc1 app/models/katello/host_collection_hosts.rb
katello-3.3.1.1 app/models/katello/host_collection_hosts.rb
katello-3.3.1 app/models/katello/host_collection_hosts.rb
katello-3.3.0.1 app/models/katello/host_collection_hosts.rb
katello-3.3.0 app/models/katello/host_collection_hosts.rb
katello-3.3.0.rc2 app/models/katello/host_collection_hosts.rb
katello-3.3.0.rc1.1 app/models/katello/host_collection_hosts.rb
katello-3.3.0.rc1 app/models/katello/host_collection_hosts.rb
katello-3.2.1.1 app/models/katello/host_collection_hosts.rb
katello-3.2.1 app/models/katello/host_collection_hosts.rb
katello-3.2.0 app/models/katello/host_collection_hosts.rb