Commit 31fdcac1 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

UserTeam: Fixed bug when impossible to change admin flag after checked

parent 6e5b1686
......@@ -25,23 +25,28 @@ module Gitlab
def update_team_user_membership(team, member, options)
updates = {}
if options[:default_projects_access] && options[:default_projects_access].to_s != team.default_projects_access(member).to_s
updates[:permission] = options[:default_projects_access]
if options[:default_projects_access].present?
default_projects_access = options[:default_projects_access].to_s
if default_projects_access != team.default_projects_access(member).to_s
updates[:permission] = default_projects_access
end
end
if options[:group_admin].to_s != team.admin?(member).to_s
updates[:group_admin] = options[:group_admin].present?
if options[:group_admin].present?
group_admin = options[:group_admin].to_s == "1" ? true : false
if group_admin != team.admin?(member)
updates[:group_admin] = group_admin
end
end
return true if updates.blank?
user_team_relationship = team.user_team_user_relationships.find_by_user_id(member)
return false unless user_team_relationship.update_attributes(updates)
if updates[:permission]
rebuild_project_permissions_to_member(team, member)
end
rebuild_project_permissions_to_member(team, member) if updates[:permission]
true
end
......
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