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
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
9653ff7a
Commit
9653ff7a
authored
Sep 19, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve conflict in app/controllers/autocomplete_controller.rb
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
580f19b8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
56 deletions
+36
-56
app/controllers/autocomplete_controller.rb
app/controllers/autocomplete_controller.rb
+0
-55
app/finders/autocomplete_users_finder.rb
app/finders/autocomplete_users_finder.rb
+36
-1
No files found.
app/controllers/autocomplete_controller.rb
View file @
9653ff7a
...
...
@@ -2,40 +2,11 @@ class AutocompleteController < ApplicationController
AWARD_EMOJI_MAX
=
100
skip_before_action
:authenticate_user!
,
only:
[
:users
,
:award_emojis
]
<<<<<<<
HEAD
before_action
:load_project
,
only:
[
:users
,
:project_groups
]
before_action
:find_users
,
only:
[
:users
]
def
users
@users
=
@users
.
non_ldap
if
params
[
:skip_ldap
]
==
'true'
@users
=
@users
.
active
@users
=
@users
.
reorder
(
:name
)
@users
=
@users
.
search
(
params
[
:search
])
if
params
[
:search
].
present?
@users
=
@users
.
where
.
not
(
id:
params
[
:skip_users
])
if
params
[
:skip_users
].
present?
@users
=
load_users_by_ability
||
@users
.
page
(
params
[
:page
]).
per
(
params
[
:per_page
])
if
params
[
:todo_filter
].
present?
&&
current_user
@users
=
@users
.
todo_authors
(
current_user
.
id
,
params
[
:todo_state_filter
])
end
if
params
[
:search
].
blank?
# Include current user if available to filter by "Me"
if
params
[
:current_user
].
present?
&&
current_user
@users
=
[
current_user
,
*
@users
].
uniq
end
if
params
[
:author_id
].
present?
&&
current_user
author
=
User
.
find_by_id
(
params
[
:author_id
])
@users
=
[
author
,
*
@users
].
uniq
if
author
end
end
=======
before_action
:load_project
,
only:
[
:users
]
before_action
:load_group
,
only:
[
:users
]
def
users
@users
=
AutocompleteUsersFinder
.
new
(
params:
params
,
current_user:
current_user
,
project:
@project
,
group:
@group
).
execute
>>>>>>>
ce
-
com
/
master
render
json:
@users
,
only:
[
:name
,
:username
,
:id
],
methods:
[
:avatar_url
]
end
...
...
@@ -72,35 +43,9 @@ class AutocompleteController < ApplicationController
private
<<<<<<<
HEAD
def
load_users_by_ability
ability
=
:push_code_to_protected_branches
if
params
[
:push_code_to_protected_branches
].
present?
ability
=
:push_code
if
params
[
:push_code
].
present?
return
if
params
[
:project_id
].
blank?
return
if
ability
.
blank?
@users
.
to_a
.
select
{
|
user
|
user
.
can?
(
ability
,
@project
)
}
.
take
(
params
[
:per_page
]
&
.
to_i
||
Kaminari
.
config
.
default_per_page
)
end
def
find_users
@users
=
if
@project
user_ids
=
@project
.
team
.
users
.
pluck
(
:id
)
if
params
[
:author_id
].
present?
user_ids
<<
params
[
:author_id
]
end
User
.
where
(
id:
user_ids
)
elsif
params
[
:group_id
].
present?
=======
def
load_group
@group
||=
begin
if
@project
.
blank?
&&
params
[
:group_id
].
present?
>>>>>>>
ce
-
com
/
master
group
=
Group
.
find
(
params
[
:group_id
])
return
render_404
unless
can?
(
current_user
,
:read_group
,
group
)
group
...
...
app/finders/autocomplete_users_finder.rb
View file @
9653ff7a
...
...
@@ -2,6 +2,9 @@ class AutocompleteUsersFinder
attr_reader
:current_user
,
:project
,
:group
,
:search
,
:skip_users
,
:page
,
:per_page
,
:author_id
,
:params
# EE
attr_reader
:skip_ldap
def
initialize
(
params
:,
current_user
:,
project
:,
group
:)
@current_user
=
current_user
@project
=
project
...
...
@@ -12,15 +15,26 @@ class AutocompleteUsersFinder
@per_page
=
params
[
:per_page
]
@author_id
=
params
[
:author_id
]
@params
=
params
# EE
@skip_ldap
=
params
[
:skip_ldap
]
end
def
execute
items
=
find_users
# EE
items
=
items
.
non_ldap
if
skip_ldap
==
'true'
items
=
items
.
active
items
=
items
.
reorder
(
:name
)
items
=
items
.
search
(
search
)
if
search
.
present?
items
=
items
.
where
.
not
(
id:
skip_users
)
if
skip_users
.
present?
items
=
items
.
page
(
page
).
per
(
per_page
)
# EE
items_by_push_ability
=
load_users_by_push_ability
(
items
)
items
=
items
.
page
(
page
).
per
(
per_page
)
unless
items_by_push_ability
# EE
if
params
[
:todo_filter
].
present?
&&
current_user
items
=
items
.
todo_authors
(
current_user
.
id
,
params
[
:todo_state_filter
])
...
...
@@ -57,4 +71,25 @@ class AutocompleteUsersFinder
User
.
where
(
id:
user_ids
)
end
# EE
def
load_users_by_push_ability
(
items
)
return
unless
project
ability
=
push_ability
return
if
ability
.
blank?
items
.
to_a
.
select
{
|
user
|
user
.
can?
(
ability
,
project
)
}
.
take
(
per_page
&
.
to_i
||
Kaminari
.
config
.
default_per_page
)
end
def
push_ability
if
params
[
:push_code_to_protected_branches
].
present?
:push_code_to_protected_branches
elsif
params
[
:push_code
].
present?
:push_code
end
end
# EE
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