Skip to content
Snippets Groups Projects
Commit 7d3efec7 authored by Andrey Kumanyaev's avatar Andrey Kumanyaev Committed by Dmitriy Zaporozhets
Browse files

Add ability to teams

parent 695becc4
No related branches found
No related tags found
2 merge requests!2940Expanding repos and hooks paths in settings,!2746New feature: Teams
Loading
Loading
@@ -8,6 +8,7 @@ class Ability
when "Snippet" then snippet_abilities(object, subject)
when "MergeRequest" then merge_request_abilities(object, subject)
when "Group", "Namespace" then group_abilities(object, subject)
when "UserTeam" then user_team_abilities(object, subject)
else []
end
end
Loading
Loading
@@ -110,6 +111,22 @@ class Ability
rules.flatten
end
 
def user_team_abilities user, team
rules = []
# Only group owner and administrators can manage group
if team.owner == user || team.admin?(user) || user.admin?
rules << [ :manage_user_team ]
end
if team.owner == user || user.admin?
rules << [ :admin_user_team ]
end
rules.flatten
end
[:issue, :note, :snippet, :merge_request].each do |name|
define_method "#{name}_abilities" do |user, subject|
if subject.author == user
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment