Module: ForemanDeployments::Concerns::BelongsToSingleTaxonomy::ClassMethods

Defined in:
app/models/foreman_deployments/concerns/belongs_to_single_taxonomy.rb

Instance Method Summary collapse

Instance Method Details

#taxonomy_conditionsObject



31
32
33
34
35
36
37
38
# File 'app/models/foreman_deployments/concerns/belongs_to_single_taxonomy.rb', line 31

def taxonomy_conditions
  org = Organization.expand(Organization.current) if SETTINGS[:organizations_enabled]
  loc = Location.expand(Location.current) if SETTINGS[:locations_enabled]
  conditions = {}
  conditions[:organization_id] = Array(org).map(&:subtree_ids).flatten.uniq if org.present?
  conditions[:location_id] = Array(loc).map(&:subtree_ids).flatten.uniq if loc.present?
  conditions
end