BigW Consortium Gitlab

projects_controller.rb 1.34 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 committed
5 6

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

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.sort(@sort = params[:sort])
16
    @projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(20)
gitlabhq committed
17 18 19
  end

  def show
20 21 22
  end

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

    if result
      redirect_to [:admin, @project]
    else
      render :show
    end
gitlabhq committed
30 31
  end

32 33 34 35 36
  protected

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

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

  def group
    @group ||= project.group
  end

  def repository
    @repository ||= project.repository
  end
gitlabhq committed
48
end