6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'app/models/concerns/foreman_puppet/extensions/user.rb', line 6
def visible_environments
authorized_scope = Environment.unscoped.authorized(:view_environments)
authorized_scope = authorized_scope
.joins(:taxable_taxonomies)
.where('taxable_taxonomies.taxonomy_id' => taxonomy_ids[:organizations] + taxonomy_ids[:locations])
result = authorized_scope.distinct.pluck(:name)
if User.current.admin?
untaxed_environments = Environment.unscoped.where.not(id: TaxableTaxonomy.where(taxable_type: 'ForemanPuppet::Environment').distinct.select(:taxable_id)).pluck(:name)
result += untaxed_environments
end
result
end
|