diff options
author | Sean McGivern <sean@gitlab.com> | 2016-08-18 19:01:50 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2016-08-18 23:09:17 +0300 |
commit | 396f85e438ddc9bcd89f5a557980ce82b71e098b (patch) | |
tree | 107f557ebf32d9cb76111edb36c656c54d80f5cc /app/models | |
parent | 8b1656282bcc39a0c1c7a3dccf74c98b1c3adae2 (diff) |
Add expiration date to group memberships
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/group.rb | 24 | ||||
-rw-r--r-- | app/models/project.rb | 4 | ||||
-rw-r--r-- | app/models/project_team.rb | 6 |
3 files changed, 20 insertions, 14 deletions
diff --git a/app/models/group.rb b/app/models/group.rb index 11c39bbdfe4..c48869ae465 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -95,34 +95,40 @@ class Group < Namespace end end - def add_users(user_ids, access_level, current_user = nil) + def add_users(user_ids, access_level, current_user: nil, expires_at: nil) user_ids.each do |user_id| - Member.add_user(self.group_members, user_id, access_level, current_user: current_user) + Member.add_user( + self.group_members, + user_id, + access_level, + current_user: current_user, + expires_at: expires_at + ) end end - def add_user(user, access_level, current_user = nil) - add_users([user], access_level, current_user) + def add_user(user, access_level, current_user: nil, expires_at: nil) + add_users([user], access_level, current_user: current_user, expires_at: expires_at) end def add_guest(user, current_user = nil) - add_user(user, Gitlab::Access::GUEST, current_user) + add_user(user, Gitlab::Access::GUEST, current_user: current_user) end def add_reporter(user, current_user = nil) - add_user(user, Gitlab::Access::REPORTER, current_user) + add_user(user, Gitlab::Access::REPORTER, current_user: current_user) end def add_developer(user, current_user = nil) - add_user(user, Gitlab::Access::DEVELOPER, current_user) + add_user(user, Gitlab::Access::DEVELOPER, current_user: current_user) end def add_master(user, current_user = nil) - add_user(user, Gitlab::Access::MASTER, current_user) + add_user(user, Gitlab::Access::MASTER, current_user: current_user) end def add_owner(user, current_user = nil) - add_user(user, Gitlab::Access::OWNER, current_user) + add_user(user, Gitlab::Access::OWNER, current_user: current_user) end def has_owner?(user) diff --git a/app/models/project.rb b/app/models/project.rb index 043da030468..f9c48a546e6 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1003,8 +1003,8 @@ class Project < ActiveRecord::Base project_members.find_by(user_id: user) end - def add_user(user, access_level, current_user = nil) - team.add_user(user, access_level, current_user) + def add_user(user, access_level, current_user: nil, expires_at: nil) + team.add_user(user, access_level, current_user: current_user, expires_at: expires_at) end def default_branch diff --git a/app/models/project_team.rb b/app/models/project_team.rb index a65d271d262..ab6ea2aae36 100644 --- a/app/models/project_team.rb +++ b/app/models/project_team.rb @@ -17,7 +17,7 @@ class ProjectTeam if users.respond_to?(:each) add_users(users, access, current_user: current_user) else - add_user(users, access, current_user) + add_user(users, access, current_user: current_user) end end @@ -43,8 +43,8 @@ class ProjectTeam ) end - def add_user(user, access, current_user = nil) - add_users([user], access, current_user: current_user) + def add_user(user, access, current_user: nil, expires_at: nil) + add_users([user], access, current_user: current_user, expires_at: expires_at) end # Remove all users from project team |