Commit 2193ae22 authored by Timothy Andrew's avatar Timothy Andrew

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.
parent 0e2cecfd
...@@ -55,11 +55,8 @@ class AutocompleteController < ApplicationController ...@@ -55,11 +55,8 @@ class AutocompleteController < ApplicationController
def find_users def find_users
@users = @users =
if params[:project_id].present? if @project
project = Project.find(params[:project_id]) @project.team.users
return render_404 unless can?(current_user, :read_project, project)
project.team.users
elsif params[:group_id].present? elsif params[:group_id].present?
group = Group.find(params[:group_id]) group = Group.find(params[:group_id])
return render_404 unless can?(current_user, :read_group, group) return render_404 unless can?(current_user, :read_group, group)
...@@ -71,4 +68,14 @@ class AutocompleteController < ApplicationController ...@@ -71,4 +68,14 @@ class AutocompleteController < ApplicationController
User.none User.none
end end
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 end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment