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
|
|
|
|
enable :create_projects
|
|
|
|
enable :admin_namespace
|
2017-11-23 09:47:15 -05:00
|
|
|
enable :read_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
|