summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2016-08-16 15:16:08 +0530
committerTimothy Andrew <mail@timothyandrew.net>2016-08-16 15:16:08 +0530
commit2193ae222b3337f03c18dd7d27408a1b138c2f92 (patch)
treed7f7e128fb1481d4d83e4df24a23fd09925c0dd5 /app
parent0e2cecfd628f00e19c33d84f76e2859ebf8a073e (diff)
downloadgitlab-ce-2193ae222b3337f03c18dd7d27408a1b138c2f92.tar.gz
Backport `AutocompleteController#load_project` from EE!581.
- This is an optimization that was made in !581, and it needs to be backported to CE to avoid merge conflicts in the future.
Diffstat (limited to 'app')
-rw-r--r--app/controllers/autocomplete_controller.rb17
1 files changed, 12 insertions, 5 deletions
diff --git a/app/controllers/autocomplete_controller.rb b/app/controllers/autocomplete_controller.rb
index d828d163c28..441030fb545 100644
--- a/app/controllers/autocomplete_controller.rb
+++ b/app/controllers/autocomplete_controller.rb
@@ -55,11 +55,8 @@ class AutocompleteController < ApplicationController
def find_users
@users =
- if params[:project_id].present?
- project = Project.find(params[:project_id])
- return render_404 unless can?(current_user, :read_project, project)
-
- project.team.users
+ if @project
+ @project.team.users
elsif params[:group_id].present?
group = Group.find(params[:group_id])
return render_404 unless can?(current_user, :read_group, group)
@@ -71,4 +68,14 @@ class AutocompleteController < ApplicationController
User.none
end
end
+
+ def load_project
+ @project ||= begin
+ if params[:project_id].present?
+ project = Project.find(params[:project_id])
+ return render_404 unless can?(current_user, :read_project, project)
+ project
+ end
+ end
+ end
end