11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'app/models/concerns/foreman_puppet/extensions/user.rb', line 11
def visible_environments
authorized_scope = ForemanPuppet::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_env_ids = TaxableTaxonomy.where(taxable_type: 'ForemanPuppet::Environment').distinct.select(:taxable_id)
untaxed_environments = ForemanPuppet::Environment.unscoped.where.not(id: untaxed_env_ids).pluck(:name)
result += untaxed_environments
end
result
end
|