diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-09-14 19:32:51 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-09-14 19:32:51 +0300 |
commit | c69b8e04591907d030b2cd544a606fd0e576116a (patch) | |
tree | 317db4259219bc7f3a3ff6e3c38c802a8d086d2c /app/models/group.rb | |
parent | eb4a9bfbca5427e6b9a8fcf2ed0b1f9f96ae099d (diff) | |
download | gitlab-ce-c69b8e04591907d030b2cd544a606fd0e576116a.tar.gz |
Huge replace of old users_project and users_group references
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/models/group.rb')
-rw-r--r-- | app/models/group.rb | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/app/models/group.rb b/app/models/group.rb index 66239f7fe6f..b8ed3b8ac73 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -17,8 +17,8 @@ require 'carrierwave/orm/activerecord' require 'file_size_validator' class Group < Namespace - has_many :users_groups, dependent: :destroy - has_many :users, through: :users_groups + has_many :group_members, dependent: :destroy, as: :source, class_name: 'GroupMember' + has_many :users, through: :group_members validate :avatar_type, if: ->(user) { user.avatar_changed? } validates :avatar, file_size: { maximum: 100.kilobytes.to_i } @@ -30,22 +30,22 @@ class Group < Namespace end def owners - @owners ||= users_groups.owners.map(&:user) + @owners ||= group_members.owners.map(&:user) end - def add_users(user_ids, group_access) + def add_users(user_ids, access_level) user_ids.compact.each do |user_id| - user = self.users_groups.find_or_initialize_by(user_id: user_id) - user.update_attributes(group_access: group_access) + user = self.group_members.find_or_initialize_by(user_id: user_id) + user.update_attributes(access_level: access_level) end end - def add_user(user, group_access) - self.users_groups.create(user_id: user.id, group_access: group_access) + def add_user(user, access_level) + self.group_members.create(user_id: user.id, access_level: access_level) end def add_owner(user) - self.add_user(user, UsersGroup::OWNER) + self.add_user(user, Gitlab::Access::OWNER) end def has_owner?(user) @@ -61,7 +61,7 @@ class Group < Namespace end def members - users_groups + group_members end def avatar_type |