Sha256: 0794e68e0acc2bd642181369f368a52cba5b70e643b63e52d48d218ce0219d63

Contents?: true

Size: 582 Bytes

Versions: 5

Compression:

Stored size: 582 Bytes

Contents

class Location < Taxonomy
  include Foreman::ThreadSession::LocationModel

  has_and_belongs_to_many :organizations
  has_many_hosts :dependent => :nullify

  scope :completer_scope, lambda { my_locations }

  scope :my_locations, lambda {
        user = User.current
        if user.admin?
          conditions = { }
        else
          conditions = sanitize_sql_for_conditions([" (taxonomies.id in (?))", user.location_ids])
        end
        where(conditions).reorder('type, name')
      }

  def dup
    new = super
    new.organizations = organizations
    new
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

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