projects_controller.rb 1.24 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
8
9
10
    owner_id = params[:owner_id]
    user = User.find_by_id(owner_id)

    @projects = user ? user.owned_projects : Project.scoped
11
    @projects = @projects.where(public: true) if params[:public_only].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
22
23
24
25
26
27
28
  end

  def transfer
    result = ::Projects::TransferContext.new(@project, current_user, project: params).execute(:admin)

    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