scinote-web/app/permissions/repository_column.rb
aignatov-bio 1c50081de5
Add stock management toggling [SCI-6653] (#3967)
Co-authored-by: Anton <anton@scinote.net>
2022-03-29 12:33:28 +02:00

16 lines
584 B
Ruby

# frozen_string_literal: true
Canaid::Permissions.register_for(RepositoryColumn) do
# repository: update/delete field
# Tested in scope of RepositoryPermissions spec
can :manage_repository_column do |user, repository_column|
managable = repository_column.repository.repository_snapshots.provisioning.none? &&
can_create_repository_columns?(user, repository_column.repository)
if repository_column.data_type == 'RepositoryStockValue'
managable = can_manage_repository_stock?(user, repository_column.repository) && managable
end
managable
end
end