Sha256: 94cd9dad2520dd267e74f17037808a7411fb90567a14e188e2b8913f4f48f6fa

Contents?: true

Size: 680 Bytes

Versions: 5

Compression:

Stored size: 680 Bytes

Contents

class DomainParameter < Parameter
  belongs_to :domain, :foreign_key => :reference_id
  audited :except => [:priority], :associated_with => :domain
  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}_domains".to_sym)
      if current.domains.empty? or current.domains.include? domain
        return true
      end
    end

    errors.add(:base, _("You do not have permission to %s this domain 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/domain_parameter.rb
foreman_discovery-1.0.0.rc4 test/foreman_app/app/models/domain_parameter.rb
foreman_discovery-1.0.0.rc3 test/foreman_app/app/models/domain_parameter.rb
foreman_discovery-1.0.0.rc2 test/foreman_app/app/models/domain_parameter.rb
foreman_discovery-1.0.0.rc1 test/foreman_app/app/models/domain_parameter.rb