Add ability to teams
This commit is contained in:
parent
695becc4cb
commit
7d3efec7d1
1 changed files with 17 additions and 0 deletions
|
@ -8,6 +8,7 @@ class Ability
|
||||||
when "Snippet" then snippet_abilities(object, subject)
|
when "Snippet" then snippet_abilities(object, subject)
|
||||||
when "MergeRequest" then merge_request_abilities(object, subject)
|
when "MergeRequest" then merge_request_abilities(object, subject)
|
||||||
when "Group", "Namespace" then group_abilities(object, subject)
|
when "Group", "Namespace" then group_abilities(object, subject)
|
||||||
|
when "UserTeam" then user_team_abilities(object, subject)
|
||||||
else []
|
else []
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -110,6 +111,22 @@ class Ability
|
||||||
rules.flatten
|
rules.flatten
|
||||||
end
|
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|
|
[:issue, :note, :snippet, :merge_request].each do |name|
|
||||||
define_method "#{name}_abilities" do |user, subject|
|
define_method "#{name}_abilities" do |user, subject|
|
||||||
if subject.author == user
|
if subject.author == user
|
||||||
|
|
Loading…
Reference in a new issue