Welcome to mirror list, hosted at ThFree Co, Russian Federation.

autocomplete_controller.rb « controllers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 11af9895261f1a683df092e4f03d9dad02a6e0c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class AutocompleteController < ApplicationController
  def users
    @users =
      if params[:project_id].present?
        project = Project.find(params[:project_id])

        if can?(current_user, :read_project, project)
          project.team.users
        end
      elsif params[:group_id]
        group = Group.find(params[:group_id])

        if can?(current_user, :read_group, group)
          group.users
        end
      else
        User.all
      end

    @users = @users.search(params[:search]) if params[:search].present?
    @users = @users.active
    @users = @users.page(params[:page]).per(PER_PAGE)
    render json: @users, only: [:name, :username, :id], methods: [:avatar_url]
  end

  def user
    @user = User.find(params[:id])
    render json: @user, only: [:name, :username, :id], methods: [:avatar_url]
  end
end