Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
bbdf2326
Commit
bbdf2326
authored
Mar 13, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `member` instead of `tm`.
parent
31fc73f0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
33 deletions
+33
-33
app/models/project_team.rb
app/models/project_team.rb
+21
-21
app/services/notification_service.rb
app/services/notification_service.rb
+12
-12
No files found.
app/models/project_team.rb
View file @
bbdf2326
...
@@ -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
)
...
...
app/services/notification_service.rb
View file @
bbdf2326
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment