From e3f88b07d04f66576e43d930fe7e8b360b6a85b9 Mon Sep 17 00:00:00 2001 From: Alexander Demichev Date: Thu, 6 Sep 2018 11:30:59 +0200 Subject: [PATCH] Add template filtering by tenant and visibility --- .../manageiq/providers/cloud_manager/template.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/models/manageiq/providers/cloud_manager/template.rb b/app/models/manageiq/providers/cloud_manager/template.rb index d30781820701..e3813d03b600 100644 --- a/app/models/manageiq/providers/cloud_manager/template.rb +++ b/app/models/manageiq/providers/cloud_manager/template.rb @@ -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