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
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
)
...
...
app/services/notification_service.rb
View file @
bbdf2326
...
...
@@ -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
...
...
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