2013-01-20 06:20:50 -05:00
|
|
|
class Admin::ProjectsController < Admin::ApplicationController
|
2015-04-16 08:03:37 -04:00
|
|
|
before_action :project, only: [:show, :transfer]
|
|
|
|
before_action :group, only: [:show, :transfer]
|
|
|
|
before_action :repository, only: [:show, :transfer]
|
2011-10-08 17:36:38 -04:00
|
|
|
|
|
|
|
def index
|
2014-06-03 07:19:11 -04:00
|
|
|
@projects = Project.all
|
|
|
|
@projects = @projects.where(namespace_id: params[:namespace_id]) if params[:namespace_id].present?
|
2013-11-06 10:13:21 -05:00
|
|
|
@projects = @projects.where("visibility_level IN (?)", params[:visibility_levels]) if params[:visibility_levels].present?
|
2013-01-14 02:44:27 -05:00
|
|
|
@projects = @projects.with_push if params[:with_push].present?
|
2013-01-14 02:37:29 -05:00
|
|
|
@projects = @projects.abandoned if params[:abandoned].present?
|
2012-11-22 23:31:09 -05:00
|
|
|
@projects = @projects.search(params[:name]) if params[:name].present?
|
2014-05-02 10:02:57 -04:00
|
|
|
@projects = @projects.sort(@sort = params[:sort])
|
2015-03-12 18:37:00 -04:00
|
|
|
@projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(PER_PAGE)
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
2014-06-02 14:25:01 -04:00
|
|
|
if @group
|
2015-03-12 18:37:00 -04:00
|
|
|
@group_members = @group.members.order("access_level DESC").page(params[:group_members_page]).per(PER_PAGE)
|
2014-06-02 14:25:01 -04:00
|
|
|
end
|
|
|
|
|
2015-03-12 18:37:00 -04:00
|
|
|
@project_members = @project.project_members.page(params[:project_members_page]).per(PER_PAGE)
|
2013-11-15 08:25:37 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def transfer
|
2014-06-19 06:20:42 -04:00
|
|
|
::Projects::TransferService.new(@project, current_user, params.dup).execute
|
2013-11-15 08:25:37 -05:00
|
|
|
|
2015-01-24 13:02:58 -05:00
|
|
|
@project.reload
|
|
|
|
redirect_to admin_namespace_project_path(@project.namespace, @project)
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
2012-11-23 15:25:28 -05:00
|
|
|
protected
|
|
|
|
|
|
|
|
def project
|
2015-01-24 13:02:58 -05:00
|
|
|
@project = Project.find_with_namespace(
|
|
|
|
[params[:namespace_id], '/', params[:id]].join('')
|
|
|
|
)
|
2012-11-23 15:25:28 -05:00
|
|
|
@project || render_404
|
|
|
|
end
|
2013-11-15 08:25:37 -05:00
|
|
|
|
|
|
|
def group
|
2014-10-19 17:20:55 -04:00
|
|
|
@group ||= @project.group
|
2013-11-15 08:25:37 -05:00
|
|
|
end
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|