2023-09-17 00:45:57 +03:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
class Ability
|
|
|
|
|
include CanCan::Ability
|
|
|
|
|
|
|
|
|
|
def initialize(user)
|
2025-05-11 16:11:02 +03:00
|
|
|
can %i[read create update], Template, Abilities::TemplateConditions.collection(user) do |template|
|
2024-02-03 22:37:17 +02:00
|
|
|
Abilities::TemplateConditions.entity(template, user:, ability: 'manage')
|
|
|
|
|
end
|
|
|
|
|
|
2025-05-11 16:11:02 +03:00
|
|
|
can :destroy, Template, account_id: user.account_id
|
2023-09-21 00:23:38 +03:00
|
|
|
can :manage, TemplateFolder, account_id: user.account_id
|
2024-02-03 22:37:17 +02:00
|
|
|
can :manage, TemplateSharing, template: { account_id: user.account_id }
|
2024-02-03 14:39:28 +02:00
|
|
|
can :manage, Submission, account_id: user.account_id
|
2024-08-16 10:58:51 +03:00
|
|
|
can :manage, Submitter, account_id: user.account_id
|
2023-09-17 00:45:57 +03:00
|
|
|
can :manage, User, account_id: user.account_id
|
|
|
|
|
can :manage, EncryptedConfig, account_id: user.account_id
|
2023-09-25 01:57:10 +03:00
|
|
|
can :manage, EncryptedUserConfig, user_id: user.id
|
2023-09-17 00:45:57 +03:00
|
|
|
can :manage, AccountConfig, account_id: user.account_id
|
2023-09-22 21:50:39 +03:00
|
|
|
can :manage, UserConfig, user_id: user.id
|
2023-09-17 00:45:57 +03:00
|
|
|
can :manage, Account, id: user.account_id
|
|
|
|
|
can :manage, AccessToken, user_id: user.id
|
2024-10-28 20:39:09 +02:00
|
|
|
can :manage, WebhookUrl, account_id: user.account_id
|
2023-09-17 00:45:57 +03:00
|
|
|
end
|
|
|
|
|
end
|