BigW Consortium Gitlab

projects_controller.rb 2.32 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
    params[:sort] ||= 'latest_activity_desc'
7
    @projects = Project.with_statistics
8
    @projects = @projects.in_namespace(params[:namespace_id]) if params[:namespace_id].present?
9
    @projects = @projects.where(visibility_level: params[:visibility_level]) if params[:visibility_level].present?
10
    @projects = @projects.with_push if params[:with_push].present?
11
    @projects = @projects.abandoned if params[:abandoned].present?
12
    @projects = @projects.where(last_repository_check_failed: true) if params[:last_repository_check_failed].present?
13 14
    @projects = @projects.non_archived unless params[:archived].present?
    @projects = @projects.personal(current_user) if params[:personal].present?
15
    @projects = @projects.search(params[:name]) if params[:name].present?
16
    @projects = @projects.sort(@sort = params[:sort])
17
    @projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page])
18 19 20 21 22 23 24 25 26

    respond_to do |format|
      format.html
      format.json do
        render json: {
          html: view_to_html_string("admin/projects/_projects", locals: { projects: @projects })
        }
      end
    end
gitlabhq committed
27 28 29
  end

  def show
30
    if @group
31
      @group_members = @group.members.order("access_level DESC").page(params[:group_members_page])
32 33
    end

34
    @project_members = @project.members.page(params[:project_members_page])
35
    @requesters = AccessRequestsFinder.new(@project).execute(current_user)
36 37 38
  end

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

Vinnie Okada committed
42 43
    @project.reload
    redirect_to admin_namespace_project_path(@project.namespace, @project)
gitlabhq committed
44 45
  end

46
  def repository_check
47
    RepositoryCheck::SingleRepositoryWorker.perform_async(@project.id)
Jacob Vosmaer committed
48 49 50

    redirect_to(
      admin_namespace_project_path(@project.namespace, @project),
Jacob Vosmaer committed
51
      notice: 'Repository check was triggered.'
Jacob Vosmaer committed
52 53 54
    )
  end

55 56 57
  protected

  def project
58
    @project = Project.find_by_full_path(
Vinnie Okada committed
59 60
      [params[:namespace_id], '/', params[:id]].join('')
    )
61 62
    @project || render_404
  end
63 64

  def group
65
    @group ||= @project.group
66
  end
gitlabhq committed
67
end