BigW Consortium Gitlab

projects_controller.rb 2.02 KB
Newer Older
1
class Admin::ProjectsController < Admin::ApplicationController
2
  before_action :project, only: [:show, :transfer, :repository_check]
3
  before_action :group, only: [:show, :transfer]
gitlabhq committed
4 5

  def index
6
    @projects = Project.all
7
    @projects = @projects.in_namespace(params[:namespace_id]) if params[:namespace_id].present?
8
    @projects = @projects.where(visibility_level: params[:visibility_level]) if params[:visibility_level].present?
9
    @projects = @projects.with_push if params[:with_push].present?
10
    @projects = @projects.abandoned if params[:abandoned].present?
11
    @projects = @projects.where(last_repository_check_failed: true) if params[:last_repository_check_failed].present?
12 13
    @projects = @projects.non_archived unless params[:archived].present?
    @projects = @projects.personal(current_user) if params[:personal].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])
gitlabhq committed
17 18 19
  end

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

24 25
    @project_members = @project.members.page(params[:project_members_page])
    @requesters = @project.requesters
26 27 28
  end

  def transfer
29 30
    namespace = Namespace.find_by(id: params[:new_namespace_id])
    ::Projects::TransferService.new(@project, current_user, params.dup).execute(namespace)
31

Vinnie Okada committed
32 33
    @project.reload
    redirect_to admin_namespace_project_path(@project.namespace, @project)
gitlabhq committed
34 35
  end

36
  def repository_check
37
    RepositoryCheck::SingleRepositoryWorker.perform_async(@project.id)
Jacob Vosmaer committed
38 39 40

    redirect_to(
      admin_namespace_project_path(@project.namespace, @project),
Jacob Vosmaer committed
41
      notice: 'Repository check was triggered.'
Jacob Vosmaer committed
42 43 44
    )
  end

45 46 47
  protected

  def project
Vinnie Okada committed
48 49 50
    @project = Project.find_with_namespace(
      [params[:namespace_id], '/', params[:id]].join('')
    )
51 52
    @project || render_404
  end
53 54

  def group
55
    @group ||= @project.group
56
  end
gitlabhq committed
57
end