Sha256: 26401bda34d6babc0076c4eaaef61b4c33931819e2fb21a35885ad1e5237838e

Contents?: true

Size: 692 Bytes

Versions: 5

Compression:

Stored size: 692 Bytes

Contents

class GroupParameter < Parameter
  belongs_to :hostgroup, :foreign_key => :reference_id
  audited :except => [:priority], :associated_with => :hostgroup
  validates_uniqueness_of :name, :scope => :reference_id

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

    current = User.current

    if current.allowed_to?("#{operation}_params".to_sym)
      if current.hostgroups.empty? or current.hostgroups.include? hostgroup
        return true
      end
    end

    errors.add(:base, _("You do not have permission to %s this group parameter") % operation)
    false
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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