projects_controller.rb 1.29 KB
Newer Older
1
class Admin::ProjectsController < Admin::ApplicationController
2
3
4
  before_filter :project, only: [:show, :transfer]
  before_filter :group, only: [:show, :transfer]
  before_filter :repository, only: [:show, :transfer]
gitlabhq's avatar
gitlabhq committed
5
6

  def index
7
    owner_id = params[:owner_id]
skv's avatar
skv committed
8
    user = User.find_by(id: owner_id)
9

skv's avatar
skv committed
10
    @projects = user ? user.owned_projects : Project.all
11
    @projects = @projects.where("visibility_level IN (?)", params[:visibility_levels]) if params[:visibility_levels].present?
12
    @projects = @projects.with_push if params[:with_push].present?
13
    @projects = @projects.abandoned if params[:abandoned].present?
14
    @projects = @projects.search(params[:name]) if params[:name].present?
15
    @projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(20)
gitlabhq's avatar
gitlabhq committed
16
17
18
  end

  def show
19
20
21
  end

  def transfer
22
    result = ::Projects::TransferService.new(@project, current_user, project: params).execute(:admin)
23
24
25
26
27
28

    if result
      redirect_to [:admin, @project]
    else
      render :show
    end
gitlabhq's avatar
gitlabhq committed
29
30
  end

31
32
33
34
35
  protected

  def project
    id = params[:project_id] || params[:id]

36
    @project = Project.find_with_namespace(id)
37
38
    @project || render_404
  end
39
40
41
42
43
44
45
46

  def group
    @group ||= project.group
  end

  def repository
    @repository ||= project.repository
  end
gitlabhq's avatar
gitlabhq committed
47
end