diff options
author | Andrey Kumanyaev <me@zzet.org> | 2013-01-20 15:25:16 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-01-25 00:31:24 +0400 |
commit | 9804b7df68a0ba4a1b144bc652351ad77a38fc3f (patch) | |
tree | 788c521aa4192dc95af8c063f33f3edd90174131 /lib | |
parent | 9d318db48f4d76b8493aefa80e7b29c2ea3cc1cf (diff) |
Move admin team members management to own controller
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/user_team_manager.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/gitlab/user_team_manager.rb b/lib/gitlab/user_team_manager.rb index d010c79223e..753081ea718 100644 --- a/lib/gitlab/user_team_manager.rb +++ b/lib/gitlab/user_team_manager.rb @@ -22,6 +22,38 @@ module Gitlab update_team_users_access_in_project(team, project) end + def update_team_user_membership(team, member, options) + updates = {} + + if options[:default_projects_access] && options[:default_projects_access] != team.default_projects_access(member) + updates[:permission] = options[:default_projects_access] + end + + if options[:group_admin].to_s != team.admin?(member).to_s + updates[:group_admin] = options[:group_admin].present? + end + + unless updates.blank? + user_team_relationship = team.user_team_user_relationships.find_by_user_id(member) + if user_team_relationship.update_attributes(updates) + if updates[:permission] + rebuild_project_permissions_to_member(team, member) + end + true + else + false + end + else + true + end + end + + def rebuild_project_permissions_to_member(team, member) + team.projects.each do |project| + update_team_user_access_in_project(team, member, project) + end + end + def update_team_users_access_in_project(team, project) members = team.members members.each do |member| |