BigW Consortium Gitlab

projects_controller.rb 1.51 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 8
    @projects = Project.all
    @projects = @projects.where(namespace_id: params[:namespace_id]) if params[:namespace_id].present?
9
    @projects = @projects.where("visibility_level IN (?)", params[:visibility_levels]) if params[:visibility_levels].present?
10
    @projects = @projects.with_push if params[:with_push].present?
11
    @projects = @projects.abandoned if params[:abandoned].present?
12
    @projects = @projects.search(params[:name]) if params[:name].present?
13
    @projects = @projects.sort(@sort = params[:sort])
14
    @projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(PER_PAGE)
gitlabhq committed
15 16 17
  end

  def show
18
    if @group
19
      @group_members = @group.members.order("access_level DESC").page(params[:group_members_page]).per(PER_PAGE)
20 21
    end

22
    @project_members = @project.project_members.page(params[:project_members_page]).per(PER_PAGE)
23 24 25
  end

  def transfer
26
    ::Projects::TransferService.new(@project, current_user, params.dup).execute
27

Vinnie Okada committed
28 29
    @project.reload
    redirect_to admin_namespace_project_path(@project.namespace, @project)
gitlabhq committed
30 31
  end

32 33 34
  protected

  def project
Vinnie Okada committed
35 36 37
    @project = Project.find_with_namespace(
      [params[:namespace_id], '/', params[:id]].join('')
    )
38 39
    @project || render_404
  end
40 41

  def group
42
    @group ||= @project.group
43
  end
gitlabhq committed
44
end