adjust shared templates

This commit is contained in:
Pete Matsyburka
2026-06-24 14:17:17 +03:00
parent 90c1a6f4ad
commit 432435aa23
11 changed files with 155 additions and 47 deletions
+2 -10
View File
@@ -4,16 +4,8 @@ module Abilities
module TemplateConditions
module_function
def collection(user, ability: nil)
templates = Template.where(account_id: user.account_id)
return templates unless user.account.testing?
shared_ids =
TemplateSharing.where({ ability:, account_id: [user.account_id, TemplateSharing::ALL_ID] }.compact)
.select(:template_id)
Template.where(Template.arel_table[:id].in(templates.select(:id).arel.union(:all, shared_ids.arel)))
def collection(user)
Template.where(account_id: user.account_id)
end
def entity(template, user:, ability: nil)