diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-04-10 15:25:32 +0200 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-04-14 12:08:10 +0200 |
commit | 87dd3f215f8c087d85cde7ac880c5480fd501303 (patch) | |
tree | ffb0f7dde79d9b2336de5dc55a159f7d1a02192c /app/models/members | |
parent | 717fa136a5146d45660d3d97f5671352a47a0601 (diff) | |
download | gitlab-ce-87dd3f215f8c087d85cde7ac880c5480fd501303.tar.gz |
Let members be invited from Add members pane.
Diffstat (limited to 'app/models/members')
-rw-r--r-- | app/models/members/project_member.rb | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/app/models/members/project_member.rb b/app/models/members/project_member.rb index a63d5af1219..3b3b1bd4680 100644 --- a/app/models/members/project_member.rb +++ b/app/models/members/project_member.rb @@ -60,12 +60,28 @@ class ProjectMember < Member raise "Non valid access" end + users = user_ids.map do |user_id| + (user_id if user_id.is_a?(User)) || + User.find_by(id: user_id) || + User.find_by(email: user_id) || + user_id + end + ProjectMember.transaction do project_ids.each do |project_id| - user_ids.each do |user_id| - member = ProjectMember.new(access_level: access_level, user_id: user_id) - member.source_id = project_id + project = Project.find(project_id) + + users.each do |user| + if user.is_a?(User) + member = project.project_members.find_or_initialize_by(user_id: user.id) + else + member = project.project_members.build + member.invite_email = user + end + member.created_by ||= current_user + member.access_level = access_level + member.save end end |