diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-05-30 12:25:34 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-05-30 12:25:34 +0400 |
commit | 31fdcac1612588071c08593ac3318b93f0312eec (patch) | |
tree | 49adfb563784b0876cf55f04125182d3ffb659e3 /lib | |
parent | 6e5b1686f4431386aab23cea64564718b62b3cb0 (diff) |
UserTeam: Fixed bug when impossible to change admin flag after checked
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/user_team_manager.rb | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/gitlab/user_team_manager.rb b/lib/gitlab/user_team_manager.rb index 99e6839ef65..135df9c6ba2 100644 --- a/lib/gitlab/user_team_manager.rb +++ b/lib/gitlab/user_team_manager.rb @@ -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 |