2016-09-29 09:46:39 +05:30
|
|
|
class NamespacePolicy < BasePolicy
|
2017-09-10 17:25:29 +05:30
|
|
|
rule { anonymous }.prevent_all
|
2016-09-29 09:46:39 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
condition(:personal_project, scope: :subject) { @subject.kind == 'user' }
|
|
|
|
condition(:can_create_personal_project, scope: :user) { @user.can_create_project? }
|
2017-09-10 17:25:29 +05:30
|
|
|
condition(:owner) { @subject.owner == @user }
|
|
|
|
|
|
|
|
rule { owner | admin }.policy do
|
|
|
|
enable :create_projects
|
|
|
|
enable :admin_namespace
|
2018-03-17 18:26:18 +05:30
|
|
|
enable :read_namespace
|
2016-09-29 09:46:39 +05:30
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
rule { personal_project & ~can_create_personal_project }.prevent :create_projects
|
2016-09-29 09:46:39 +05:30
|
|
|
end
|