Sha256: ca5176b00dc8d91dd8809cb1c19086d41912a1b85957c9cf7155f62cc86ff841

Contents?: true

Size: 667 Bytes

Versions: 5

Compression:

Stored size: 667 Bytes

Contents

class HostParameter < Parameter
  belongs_to_host :foreign_key => :reference_id
  audited :except => [:priority], :associated_with => :host
  validates_uniqueness_of :name, :scope => :reference_id

  def to_s
    "#{host.id ? host.name : "unassociated"}: #{name} = #{value}"
  end

  private
  def enforce_permissions operation
    # We get called again with the operation being set to create
    return true if operation == "edit" and new_record?

    (auth = User.current.allowed_to?("#{operation}_params".to_sym)) and Host.my_hosts.include?(host)

    errors.add(:base, _("You do not have permission to %s this domain") % operation) unless auth
    auth
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_discovery-1.0.0 test/foreman_app/app/models/host_parameter.rb
foreman_discovery-1.0.0.rc4 test/foreman_app/app/models/host_parameter.rb
foreman_discovery-1.0.0.rc3 test/foreman_app/app/models/host_parameter.rb
foreman_discovery-1.0.0.rc2 test/foreman_app/app/models/host_parameter.rb
foreman_discovery-1.0.0.rc1 test/foreman_app/app/models/host_parameter.rb