Commit bbdf2326 authored by Douwe Maan's avatar Douwe Maan

Use `member` instead of `tm`.

parent 31fc73f0
......@@ -31,16 +31,16 @@ class ProjectTeam
user
end
def find_tm(user_id)
tm = project.project_members.find_by(user_id: user_id)
def find_member(user_id)
member = project.project_members.find_by(user_id: user_id)
# If user is not in project members
# we should check for group membership
if group && !tm
tm = group.group_members.find_by(user_id: user_id)
if group && !member
member = group.group_members.find_by(user_id: user_id)
end
tm
member
end
def add_user(user, access)
......@@ -91,24 +91,24 @@ class ProjectTeam
def import(source_project)
target_project = project
source_team = source_project.project_members.to_a
source_members = source_project.project_members.to_a
target_user_ids = target_project.project_members.pluck(:user_id)
source_team.reject! do |tm|
source_members.reject! do |member|
# Skip if user already present in team
target_user_ids.include?(tm.user_id)
target_user_ids.include?(member.user_id)
end
source_team.map! do |tm|
new_tm = tm.dup
new_tm.id = nil
new_tm.source = target_project
new_tm
source_members.map! do |member|
new_member = member.dup
new_member.id = nil
new_member.source = target_project
new_member
end
ProjectMember.transaction do
source_team.each do |tm|
tm.save
source_members.each do |member|
member.save
end
end
......@@ -118,26 +118,26 @@ class ProjectTeam
end
def guest?(user)
max_tm_access(user.id) == Gitlab::Access::GUEST
max_member_access(user.id) == Gitlab::Access::GUEST
end
def reporter?(user)
max_tm_access(user.id) == Gitlab::Access::REPORTER
max_member_access(user.id) == Gitlab::Access::REPORTER
end
def developer?(user)
max_tm_access(user.id) == Gitlab::Access::DEVELOPER
max_member_access(user.id) == Gitlab::Access::DEVELOPER
end
def master?(user)
max_tm_access(user.id) == Gitlab::Access::MASTER
max_member_access(user.id) == Gitlab::Access::MASTER
end
def member?(user_id)
!!find_tm(user_id)
!!find_member(user_id)
end
def max_tm_access(user_id)
def max_member_access(user_id)
access = []
access << project.project_members.find_by(user_id: user_id).try(:access_field)
......
......@@ -273,20 +273,20 @@ class NotificationService
users.reject do |user|
next user.notification.disabled? unless project
tm = project.project_members.find_by(user_id: user.id)
member = project.project_members.find_by(user_id: user.id)
if !tm && project.group
tm = project.group.group_members.find_by(user_id: user.id)
if !member && project.group
member = project.group.group_members.find_by(user_id: user.id)
end
# reject users who globally disabled notification and has no membership
next user.notification.disabled? unless tm
next user.notification.disabled? unless member
# reject users who disabled notification in project
next true if tm.notification.disabled?
next true if member.notification.disabled?
# reject users who have N_GLOBAL in project and disabled in global settings
tm.notification.global? && user.notification.disabled?
member.notification.global? && user.notification.disabled?
end
end
......@@ -297,20 +297,20 @@ class NotificationService
users.reject do |user|
next user.notification.mention? unless project
tm = project.project_members.find_by(user_id: user.id)
member = project.project_members.find_by(user_id: user.id)
if !tm && project.group
tm = project.group.group_members.find_by(user_id: user.id)
if !member && project.group
member = project.group.group_members.find_by(user_id: user.id)
end
# reject users who globally set mention notification and has no membership
next user.notification.mention? unless tm
next user.notification.mention? unless member
# reject users who set mention notification in project
next true if tm.notification.mention?
next true if member.notification.mention?
# reject users who have N_MENTION in project and disabled in global settings
tm.notification.global? && user.notification.mention?
member.notification.global? && user.notification.mention?
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment