BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
b7b41d1f
Commit
b7b41d1f
authored
Sep 20, 2016
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify ProjectTeam#fetch_members to satisfy flog
parent
b674ab52
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
30 deletions
+40
-30
project_team.rb
app/models/project_team.rb
+40
-30
No files found.
app/models/project_team.rb
View file @
b7b41d1f
...
@@ -163,7 +163,7 @@ class ProjectTeam
...
@@ -163,7 +163,7 @@ class ProjectTeam
# Each group produces a list of maximum access level per user. We take the
# Each group produces a list of maximum access level per user. We take the
# max of the values produced by each group.
# max of the values produced by each group.
if
project
.
invited_groups
.
any?
&&
project
.
allowed_to_share
_with_group?
if
project
_shared
_with_group?
project
.
project_group_links
.
each
do
|
group_link
|
project
.
project_group_links
.
each
do
|
group_link
|
invited_access
=
max_invited_level_for_users
(
group_link
,
user_ids
)
invited_access
=
max_invited_level_for_users
(
group_link
,
user_ids
)
merge_max!
(
access
,
invited_access
)
merge_max!
(
access
,
invited_access
)
...
@@ -200,35 +200,6 @@ class ProjectTeam
...
@@ -200,35 +200,6 @@ class ProjectTeam
def
fetch_members
(
level
=
nil
)
def
fetch_members
(
level
=
nil
)
project_members
=
project
.
members
project_members
=
project
.
members
group_members
=
group
?
group
.
members
:
[]
group_members
=
group
?
group
.
members
:
[]
invited_members
=
[]
if
project
.
invited_groups
.
any?
&&
project
.
allowed_to_share_with_group?
project
.
project_group_links
.
includes
(
group:
[
:group_members
]).
each
do
|
group_link
|
invited_group
=
group_link
.
group
im
=
invited_group
.
members
if
level
int_level
=
GroupMember
.
access_level_roles
[
level
.
to_s
.
singularize
.
titleize
]
# Skip group members if we ask for masters
# but max group access is developers
next
if
int_level
>
group_link
.
group_access
# If we ask for developers and max
# group access is developers we need to provide
# both group master, developers as devs
if
int_level
==
group_link
.
group_access
im
.
where
(
"access_level >= ?)"
,
group_link
.
group_access
)
else
im
.
send
(
level
)
end
end
invited_members
<<
im
end
invited_members
=
invited_members
.
flatten
.
compact
end
if
level
if
level
project_members
=
project_members
.
send
(
level
)
project_members
=
project_members
.
send
(
level
)
...
@@ -236,7 +207,10 @@ class ProjectTeam
...
@@ -236,7 +207,10 @@ class ProjectTeam
end
end
user_ids
=
project_members
.
pluck
(
:user_id
)
user_ids
=
project_members
.
pluck
(
:user_id
)
invited_members
=
fetch_invited_members
(
level
)
user_ids
.
push
(
*
invited_members
.
map
(
&
:user_id
))
if
invited_members
.
any?
user_ids
.
push
(
*
invited_members
.
map
(
&
:user_id
))
if
invited_members
.
any?
user_ids
.
push
(
*
group_members
.
pluck
(
:user_id
))
if
group
user_ids
.
push
(
*
group_members
.
pluck
(
:user_id
))
if
group
User
.
where
(
id:
user_ids
)
User
.
where
(
id:
user_ids
)
...
@@ -249,4 +223,40 @@ class ProjectTeam
...
@@ -249,4 +223,40 @@ class ProjectTeam
def
merge_max!
(
first_hash
,
second_hash
)
def
merge_max!
(
first_hash
,
second_hash
)
first_hash
.
merge!
(
second_hash
)
{
|
_key
,
old
,
new
|
old
>
new
?
old
:
new
}
first_hash
.
merge!
(
second_hash
)
{
|
_key
,
old
,
new
|
old
>
new
?
old
:
new
}
end
end
def
project_shared_with_group?
project
.
invited_groups
.
any?
&&
project
.
allowed_to_share_with_group?
end
def
fetch_invited_members
(
level
=
nil
)
invited_members
=
[]
return
invited_members
unless
project_shared_with_group?
project
.
project_group_links
.
includes
(
group:
[
:group_members
]).
each
do
|
group_link
|
invited_group
=
group_link
.
group
im
=
invited_group
.
members
if
level
int_level
=
GroupMember
.
access_level_roles
[
level
.
to_s
.
singularize
.
titleize
]
# Skip group members if we ask for masters
# but max group access is developers
next
if
int_level
>
group_link
.
group_access
# If we ask for developers and max
# group access is developers we need to provide
# both group master, developers as devs
if
int_level
==
group_link
.
group_access
im
.
where
(
"access_level >= ?)"
,
group_link
.
group_access
)
else
im
.
send
(
level
)
end
end
invited_members
<<
im
end
invited_members
.
flatten
.
compact
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