summaryrefslogtreecommitdiff
path: root/app/models/project_team.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-04-10 14:46:09 +0200
committerDouwe Maan <douwe@gitlab.com>2015-04-14 12:06:42 +0200
commit2b2bd402dcee427a43de771036b348e156fea6c9 (patch)
tree0f4e7723cf6bf22a08197fccb0320c87361799d4 /app/models/project_team.rb
parent1e97864958b5ee7cb92a6d45ceab6b6e476c5e7e (diff)
downloadgitlab-ce-2b2bd402dcee427a43de771036b348e156fea6c9.tar.gz
Track who created a group or project member.
Diffstat (limited to 'app/models/project_team.rb')
-rw-r--r--app/models/project_team.rb28
1 files changed, 13 insertions, 15 deletions
diff --git a/app/models/project_team.rb b/app/models/project_team.rb
index d4a07caf9ef..313e459d701 100644
--- a/app/models/project_team.rb
+++ b/app/models/project_team.rb
@@ -12,12 +12,12 @@ class ProjectTeam
# @team << [@users, :master]
#
def <<(args)
- users = args.first
+ users, access, current_user = *args
if users.respond_to?(:each)
- add_users(users, args.second)
+ add_users(users, access, current_user)
else
- add_user(users, args.second)
+ add_user(users, access, current_user)
end
end
@@ -43,22 +43,19 @@ class ProjectTeam
member
end
- def add_user(user, access)
- add_users_ids([user.id], access)
- end
-
- def add_users(users, access)
- add_users_ids(users.map(&:id), access)
- end
-
- def add_users_ids(user_ids, access)
+ def add_users(users, access, current_user = nil)
ProjectMember.add_users_into_projects(
[project.id],
- user_ids,
- access
+ users,
+ access,
+ current_user
)
end
+ def add_user(user, access, current_user = nil)
+ add_users([user], access, current_user)
+ end
+
# Remove all users from project team
def truncate
ProjectMember.truncate_team(project)
@@ -88,7 +85,7 @@ class ProjectTeam
@masters ||= fetch_members(:masters)
end
- def import(source_project)
+ def import(source_project, current_user = nil)
target_project = project
source_members = source_project.project_members.to_a
@@ -103,6 +100,7 @@ class ProjectTeam
new_member = member.dup
new_member.id = nil
new_member.source = target_project
+ new_member.created_by = current_user
new_member
end