Skip to content

Commit

Permalink
Add template filtering by tenant and visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Demichev committed Sep 6, 2018
1 parent bb7d748 commit e3f88b0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/models/manageiq/providers/cloud_manager/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,13 @@ def self.display_name(number = 1)

def self.tenant_id_clause(user_or_group)
template_tenant_ids = MiqTemplate.accessible_tenant_ids(user_or_group, Rbac.accessible_tenant_ids_strategy(self))
return if template_tenant_ids.empty?

["(vms.template = true AND (vms.tenant_id IN (?) OR vms.publicly_available = true))", template_tenant_ids]
tenant = User.current_user.current_group.tenant

if tenant.source_id
["(vms.template = true AND (vms.tenant_id = (?) AND vms.publicly_available = false OR vms.publicly_available = true))", tenant.id]
else
["(vms.template = true AND (vms.tenant_id IN (?) OR vms.publicly_available = true))", template_tenant_ids] unless template_tenant_ids.empty?
end
end

private
Expand Down

0 comments on commit e3f88b0

Please sign in to comment.