Commit 31fdcac1612588071c08593ac3318b93f0312eec
1 parent
6e5b1686
Exists in
master
and in
4 other branches
UserTeam: Fixed bug when impossible to change admin flag after checked
Showing
1 changed file
with
13 additions
and
8 deletions
Show diff stats
lib/gitlab/user_team_manager.rb
| @@ -25,23 +25,28 @@ module Gitlab | @@ -25,23 +25,28 @@ module Gitlab | ||
| 25 | def update_team_user_membership(team, member, options) | 25 | def update_team_user_membership(team, member, options) |
| 26 | updates = {} | 26 | updates = {} |
| 27 | 27 | ||
| 28 | - if options[:default_projects_access] && options[:default_projects_access].to_s != team.default_projects_access(member).to_s | ||
| 29 | - updates[:permission] = options[:default_projects_access] | 28 | + if options[:default_projects_access].present? |
| 29 | + default_projects_access = options[:default_projects_access].to_s | ||
| 30 | + | ||
| 31 | + if default_projects_access != team.default_projects_access(member).to_s | ||
| 32 | + updates[:permission] = default_projects_access | ||
| 33 | + end | ||
| 30 | end | 34 | end |
| 31 | 35 | ||
| 32 | - if options[:group_admin].to_s != team.admin?(member).to_s | ||
| 33 | - updates[:group_admin] = options[:group_admin].present? | 36 | + if options[:group_admin].present? |
| 37 | + group_admin = options[:group_admin].to_s == "1" ? true : false | ||
| 38 | + | ||
| 39 | + if group_admin != team.admin?(member) | ||
| 40 | + updates[:group_admin] = group_admin | ||
| 41 | + end | ||
| 34 | end | 42 | end |
| 35 | 43 | ||
| 36 | return true if updates.blank? | 44 | return true if updates.blank? |
| 37 | 45 | ||
| 38 | user_team_relationship = team.user_team_user_relationships.find_by_user_id(member) | 46 | user_team_relationship = team.user_team_user_relationships.find_by_user_id(member) |
| 39 | - | ||
| 40 | return false unless user_team_relationship.update_attributes(updates) | 47 | return false unless user_team_relationship.update_attributes(updates) |
| 41 | 48 | ||
| 42 | - if updates[:permission] | ||
| 43 | - rebuild_project_permissions_to_member(team, member) | ||
| 44 | - end | 49 | + rebuild_project_permissions_to_member(team, member) if updates[:permission] |
| 45 | 50 | ||
| 46 | true | 51 | true |
| 47 | end | 52 | end |