2018-07-24 06:00:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-18 12:52:35 -04:00
|
|
|
class NamespacePolicy < BasePolicy
|
2017-04-06 17:06:42 -04:00
|
|
|
rule { anonymous }.prevent_all
|
2016-08-18 12:52:35 -04:00
|
|
|
|
2017-09-29 07:14:39 -04:00
|
|
|
condition(:personal_project, scope: :subject) { @subject.kind == 'user' }
|
|
|
|
condition(:can_create_personal_project, scope: :user) { @user.can_create_project? }
|
2017-04-06 17:06:42 -04:00
|
|
|
condition(:owner) { @subject.owner == @user }
|
|
|
|
|
|
|
|
rule { owner | admin }.policy do
|
2020-11-27 07:09:14 -05:00
|
|
|
enable :owner_access
|
2017-04-06 17:06:42 -04:00
|
|
|
enable :create_projects
|
|
|
|
enable :admin_namespace
|
2017-11-23 09:47:15 -05:00
|
|
|
enable :read_namespace
|
2019-08-22 18:08:28 -04:00
|
|
|
enable :read_statistics
|
2020-09-01 08:11:01 -04:00
|
|
|
enable :create_jira_connect_subscription
|
2021-01-05 13:10:25 -05:00
|
|
|
enable :create_package_settings
|
|
|
|
enable :read_package_settings
|
2016-08-18 12:52:35 -04:00
|
|
|
end
|
2017-09-29 07:14:39 -04:00
|
|
|
|
|
|
|
rule { personal_project & ~can_create_personal_project }.prevent :create_projects
|
2019-09-23 03:42:26 -04:00
|
|
|
|
|
|
|
rule { (owner | admin) & can?(:create_projects) }.enable :transfer_projects
|
2016-08-18 12:52:35 -04:00
|
|
|
end
|
2019-09-13 09:26:31 -04:00
|
|
|
|
|
|
|
NamespacePolicy.prepend_if_ee('EE::NamespacePolicy')
|