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

  def index
7
    @projects = Project.all
8
    @projects = @projects.in_namespace(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.non_archived unless params[:with_archived].present?
13
    @projects = @projects.search(params[:name]) if params[:name].present?
14
    @projects = @projects.sort(@sort = params[:sort])
15
    @projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(PER_PAGE)
gitlabhq's avatar
gitlabhq committed
16
17
18
  end

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

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

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

Vinnie Okada's avatar
Vinnie Okada committed
30
31
    @project.reload
    redirect_to admin_namespace_project_path(@project.namespace, @project)
gitlabhq's avatar
gitlabhq committed
32
33
  end

34
35
36
  protected

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

  def group
44
    @group ||= @project.group
45
  end
gitlabhq's avatar
gitlabhq committed
46
end