debian-mirror-gitlab/app/policies/namespace_policy.rb

23 lines
685 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
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
2019-12-04 20:38:33 +05:30
enable :read_statistics
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
2019-10-31 01:37:42 +05:30
rule { (owner | admin) & can?(:create_projects) }.enable :transfer_projects
2016-09-29 09:46:39 +05:30
end
2019-12-04 20:38:33 +05:30
NamespacePolicy.prepend_if_ee('EE::NamespacePolicy')