BigW Consortium Gitlab

Commit bbdf2326 by Douwe Maan

Use `member` instead of `tm`.

parent 31fc73f0
...@@ -31,16 +31,16 @@ class ProjectTeam ...@@ -31,16 +31,16 @@ class ProjectTeam
user user
end end
def find_tm(user_id) def find_member(user_id)
tm = project.project_members.find_by(user_id: user_id) member = project.project_members.find_by(user_id: user_id)
# If user is not in project members # If user is not in project members
# we should check for group membership # we should check for group membership
if group && !tm if group && !member
tm = group.group_members.find_by(user_id: user_id) member = group.group_members.find_by(user_id: user_id)
end end
tm member
end end
def add_user(user, access) def add_user(user, access)
...@@ -91,24 +91,24 @@ class ProjectTeam ...@@ -91,24 +91,24 @@ class ProjectTeam
def import(source_project) def import(source_project)
target_project = 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) 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 # Skip if user already present in team
target_user_ids.include?(tm.user_id) target_user_ids.include?(member.user_id)
end end
source_team.map! do |tm| source_members.map! do |member|
new_tm = tm.dup new_member = member.dup
new_tm.id = nil new_member.id = nil
new_tm.source = target_project new_member.source = target_project
new_tm new_member
end end
ProjectMember.transaction do ProjectMember.transaction do
source_team.each do |tm| source_members.each do |member|
tm.save member.save
end end
end end
...@@ -118,26 +118,26 @@ class ProjectTeam ...@@ -118,26 +118,26 @@ class ProjectTeam
end end
def guest?(user) def guest?(user)
max_tm_access(user.id) == Gitlab::Access::GUEST max_member_access(user.id) == Gitlab::Access::GUEST
end end
def reporter?(user) def reporter?(user)
max_tm_access(user.id) == Gitlab::Access::REPORTER max_member_access(user.id) == Gitlab::Access::REPORTER
end end
def developer?(user) def developer?(user)
max_tm_access(user.id) == Gitlab::Access::DEVELOPER max_member_access(user.id) == Gitlab::Access::DEVELOPER
end end
def master?(user) def master?(user)
max_tm_access(user.id) == Gitlab::Access::MASTER max_member_access(user.id) == Gitlab::Access::MASTER
end end
def member?(user_id) def member?(user_id)
!!find_tm(user_id) !!find_member(user_id)
end end
def max_tm_access(user_id) def max_member_access(user_id)
access = [] access = []
access << project.project_members.find_by(user_id: user_id).try(:access_field) access << project.project_members.find_by(user_id: user_id).try(:access_field)
......
...@@ -273,20 +273,20 @@ class NotificationService ...@@ -273,20 +273,20 @@ class NotificationService
users.reject do |user| users.reject do |user|
next user.notification.disabled? unless project 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 if !member && project.group
tm = project.group.group_members.find_by(user_id: user.id) member = project.group.group_members.find_by(user_id: user.id)
end end
# reject users who globally disabled notification and has no membership # 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 # 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 # 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
end end
...@@ -297,20 +297,20 @@ class NotificationService ...@@ -297,20 +297,20 @@ class NotificationService
users.reject do |user| users.reject do |user|
next user.notification.mention? unless project 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 if !member && project.group
tm = project.group.group_members.find_by(user_id: user.id) member = project.group.group_members.find_by(user_id: user.id)
end end
# reject users who globally set mention notification and has no membership # 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 # 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 # 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
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