2013-01-20 11:20:50 +00:00
|
|
|
class Admin::ProjectsController < Admin::ApplicationController
|
2013-11-15 13:25:37 +00:00
|
|
|
before_filter :project, only: [:show, :transfer]
|
|
|
|
before_filter :group, only: [:show, :transfer]
|
|
|
|
before_filter :repository, only: [:show, :transfer]
|
2011-10-08 21:36:38 +00:00
|
|
|
|
|
|
|
def index
|
2013-06-11 11:17:37 +00:00
|
|
|
owner_id = params[:owner_id]
|
|
|
|
user = User.find_by_id(owner_id)
|
|
|
|
|
2013-12-14 13:43:48 +00:00
|
|
|
@projects = user ? user.owned_projects : Project.all
|
2013-11-06 15:13:21 +00:00
|
|
|
@projects = @projects.where("visibility_level IN (?)", params[:visibility_levels]) if params[:visibility_levels].present?
|
2013-01-14 07:44:27 +00:00
|
|
|
@projects = @projects.with_push if params[:with_push].present?
|
2013-01-14 07:37:29 +00:00
|
|
|
@projects = @projects.abandoned if params[:abandoned].present?
|
2012-11-23 04:31:09 +00:00
|
|
|
@projects = @projects.search(params[:name]) if params[:name].present?
|
2012-11-23 18:11:09 +00:00
|
|
|
@projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(20)
|
2011-10-08 21:36:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
2013-11-15 13:25:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def transfer
|
|
|
|
result = ::Projects::TransferContext.new(@project, current_user, project: params).execute(:admin)
|
|
|
|
|
|
|
|
if result
|
|
|
|
redirect_to [:admin, @project]
|
|
|
|
else
|
|
|
|
render :show
|
|
|
|
end
|
2011-10-08 21:36:38 +00:00
|
|
|
end
|
|
|
|
|
2012-11-23 20:25:28 +00:00
|
|
|
protected
|
|
|
|
|
|
|
|
def project
|
|
|
|
id = params[:project_id] || params[:id]
|
|
|
|
|
2012-11-25 10:26:34 +00:00
|
|
|
@project = Project.find_with_namespace(id)
|
2012-11-23 20:25:28 +00:00
|
|
|
@project || render_404
|
|
|
|
end
|
2013-11-15 13:25:37 +00:00
|
|
|
|
|
|
|
def group
|
|
|
|
@group ||= project.group
|
|
|
|
end
|
|
|
|
|
|
|
|
def repository
|
|
|
|
@repository ||= project.repository
|
|
|
|
end
|
2011-10-08 21:36:38 +00:00
|
|
|
end
|