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
|
|
|
|
enable :create_projects
|
|
|
|
enable :admin_namespace
|
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
|
2016-08-18 12:52:35 -04:00
|
|
|
end
|