Read about our upcoming Code of Conduct on this issue

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

  def index
Markus Koller's avatar
Markus Koller committed
6
    @projects = Project.with_statistics
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?
Jacob Vosmaer's avatar
Jacob Vosmaer committed
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's avatar
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
    @project_members = @project.members.page(params[:project_members_page])
Rémy Coutable's avatar
Rémy Coutable committed
25
    @requesters = AccessRequestsFinder.new(@project).execute(current_user)
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's avatar
Vinnie Okada committed
32
33
    @project.reload
    redirect_to admin_namespace_project_path(@project.namespace, @project)
gitlabhq's avatar
gitlabhq committed
34
35
  end

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

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

45
46
47
  protected

  def project
Vinnie Okada's avatar
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's avatar
gitlabhq committed
57
end