debian-mirror-gitlab/app/controllers/admin/projects_controller.rb

47 lines
1.7 KiB
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
class Admin::ProjectsController < Admin::ApplicationController
2015-09-11 14:41:01 +05:30
before_action :project, only: [:show, :transfer]
before_action :group, only: [:show, :transfer]
before_action :repository, only: [:show, :transfer]
2014-09-02 18:07:02 +05:30
def index
@projects = Project.all
2015-09-11 14:41:01 +05:30
@projects = @projects.in_namespace(params[:namespace_id]) if params[:namespace_id].present?
2014-09-02 18:07:02 +05:30
@projects = @projects.where("visibility_level IN (?)", params[:visibility_levels]) if params[:visibility_levels].present?
@projects = @projects.with_push if params[:with_push].present?
@projects = @projects.abandoned if params[:abandoned].present?
2015-09-25 12:07:36 +05:30
@projects = @projects.non_archived unless params[:with_archived].present?
2014-09-02 18:07:02 +05:30
@projects = @projects.search(params[:name]) if params[:name].present?
@projects = @projects.sort(@sort = params[:sort])
2015-04-26 12:48:37 +05:30
@projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(PER_PAGE)
2014-09-02 18:07:02 +05:30
end
def show
if @group
2015-04-26 12:48:37 +05:30
@group_members = @group.members.order("access_level DESC").page(params[:group_members_page]).per(PER_PAGE)
2014-09-02 18:07:02 +05:30
end
2015-04-26 12:48:37 +05:30
@project_members = @project.project_members.page(params[:project_members_page]).per(PER_PAGE)
2014-09-02 18:07:02 +05:30
end
def transfer
2015-09-11 14:41:01 +05:30
namespace = Namespace.find_by(id: params[:new_namespace_id])
::Projects::TransferService.new(@project, current_user, params.dup).execute(namespace)
2014-09-02 18:07:02 +05:30
2015-04-26 12:48:37 +05:30
@project.reload
redirect_to admin_namespace_project_path(@project.namespace, @project)
2014-09-02 18:07:02 +05:30
end
protected
def project
2015-04-26 12:48:37 +05:30
@project = Project.find_with_namespace(
[params[:namespace_id], '/', params[:id]].join('')
)
2014-09-02 18:07:02 +05:30
@project || render_404
end
def group
2015-04-26 12:48:37 +05:30
@group ||= @project.group
2014-09-02 18:07:02 +05:30
end
end