diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-04-10 14:46:09 +0200 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-04-14 12:06:42 +0200 |
commit | 2b2bd402dcee427a43de771036b348e156fea6c9 (patch) | |
tree | 0f4e7723cf6bf22a08197fccb0320c87361799d4 /app/models/group.rb | |
parent | 1e97864958b5ee7cb92a6d45ceab6b6e476c5e7e (diff) | |
download | gitlab-ce-2b2bd402dcee427a43de771036b348e156fea6c9.tar.gz |
Track who created a group or project member.
Diffstat (limited to 'app/models/group.rb')
-rw-r--r-- | app/models/group.rb | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/app/models/group.rb b/app/models/group.rb index da9621a2a1a..eec961f6012 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -46,19 +46,21 @@ class Group < Namespace @owners ||= group_members.owners.map(&:user) end - def add_users(user_ids, access_level) + def add_users(user_ids, access_level, current_user = nil) user_ids.compact.each do |user_id| - user = self.group_members.find_or_initialize_by(user_id: user_id) - user.update_attributes(access_level: access_level) + member = self.group_members.find_or_initialize_by(user_id: user_id) + member.access_level = access_level + member.created_by ||= current_user + member.save end end - def add_user(user, access_level) - self.group_members.create(user_id: user.id, access_level: access_level) + def add_user(user, access_level, current_user = nil) + add_users([user], access_level, current_user) end - def add_owner(user) - self.add_user(user, Gitlab::Access::OWNER) + def add_owner(user, current_user = nil) + self.add_user(user, Gitlab::Access::OWNER, current_user) end def has_owner?(user) |