diff options
author | James Lopez <james.lopez@vodafone.com> | 2015-11-03 11:11:56 +0000 |
---|---|---|
committer | James Lopez <james.lopez@vodafone.com> | 2015-11-03 11:11:56 +0000 |
commit | 1b14bc59570a625365fef232f8c57919f76b3e2a (patch) | |
tree | b1c125a96e844aedfc183ff3874bd74871f0c7af /app/models/group.rb | |
parent | 6aa9c21ac0e3f4860f9021718900326ea0575151 (diff) | |
download | gitlab-ce-1b14bc59570a625365fef232f8c57919f76b3e2a.tar.gz |
refactored permissions and added update_project_member ability logic. Also refactored owner methods to a concern.
Diffstat (limited to 'app/models/group.rb')
-rw-r--r-- | app/models/group.rb | 22 |
1 files changed, 2 insertions, 20 deletions
diff --git a/app/models/group.rb b/app/models/group.rb index 465c22d23ac..c9806f6fd6f 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -19,8 +19,10 @@ require 'file_size_validator' class Group < Namespace include Gitlab::ConfigHelper include Referable + include HasOwners has_many :group_members, dependent: :destroy, as: :source, class_name: 'GroupMember' + alias_method :my_members, :group_members has_many :users, through: :group_members validate :avatar_type, if: ->(user) { user.avatar.present? && user.avatar_changed? } @@ -63,10 +65,6 @@ class Group < Namespace end end - def owners - @owners ||= group_members.owners.includes(:user).map(&:user) - end - def add_users(user_ids, access_level, current_user = nil) user_ids.each do |user_id| Member.add_user(self.group_members, user_id, access_level, current_user) @@ -93,22 +91,6 @@ class Group < Namespace add_user(user, Gitlab::Access::MASTER, current_user) end - def add_owner(user, current_user = nil) - add_user(user, Gitlab::Access::OWNER, current_user) - end - - def has_owner?(user) - owners.include?(user) - end - - def has_master?(user) - members.masters.where(user_id: user).any? - end - - def last_owner?(user) - has_owner?(user) && owners.size == 1 - end - def members group_members end |