Commit e8e9e0f7 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Use own abilities for namespace class

parent 0273b79b
......@@ -10,7 +10,8 @@ class Ability
when "ProjectSnippet" then project_snippet_abilities(user, subject)
when "PersonalSnippet" then personal_snippet_abilities(user, subject)
when "MergeRequest" then merge_request_abilities(user, subject)
when "Group", "Namespace" then group_abilities(user, subject)
when "Group" then group_abilities(user, subject)
when "Namespace" then namespace_abilities(user, subject)
else []
end.concat(global_abilities(user))
end
......@@ -144,6 +145,19 @@ class Ability
rules.flatten
end
def namespace_abilities user, namespace
rules = []
# Only namespace owner and administrators can manage it
if namespace.owner == user || user.admin?
rules << [
:manage_namespace
]
end
rules.flatten
end
[:issue, :note, :project_snippet, :personal_snippet, :merge_request].each do |name|
define_method "#{name}_abilities" do |user, subject|
if subject.author == user
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment