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.
This commit is contained in:
Timothy Andrew 2016-08-16 15:16:08 +05:30
parent 0e2cecfd62
commit 2193ae222b
1 changed files with 12 additions and 5 deletions

View File

@ -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