2019-07-12 22:43:54 +08:00
|
|
|
# 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|
|
2022-03-29 18:33:28 +08:00
|
|
|
managable = repository_column.repository.repository_snapshots.provisioning.none? &&
|
2020-05-15 23:46:59 +08:00
|
|
|
can_create_repository_columns?(user, repository_column.repository)
|
2022-03-29 18:33:28 +08:00
|
|
|
|
|
|
|
if repository_column.data_type == 'RepositoryStockValue'
|
|
|
|
managable = can_manage_repository_stock?(user, repository_column.repository) && managable
|
|
|
|
end
|
|
|
|
|
|
|
|
managable
|
2019-07-12 22:43:54 +08:00
|
|
|
end
|
|
|
|
end
|