blob: 53ef6e939dd4bd7e32402f8abaaf06f270d707bd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# == Owners concern
#
# Contains owners functionality for groups
#
module HasOwners
extend ActiveSupport::Concern
def owners
@owners ||= members.owners.includes(:user).map(&:user)
end
def members
raise NotImplementedError, "Expected members to be defined in #{self.class.name}"
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
end
|