2013-01-20 06:20:50 -05:00
|
|
|
class Admin::ProjectsController < Admin::ApplicationController
|
2016-04-06 07:47:05 -04:00
|
|
|
before_action :project, only: [:show, :transfer, :repository_check]
|
2015-04-16 08:03:37 -04:00
|
|
|
before_action :group, only: [:show, :transfer]
|
2011-10-08 17:36:38 -04:00
|
|
|
|
|
|
|
def index
|
2014-06-03 07:19:11 -04:00
|
|
|
@projects = Project.all
|
2015-06-09 07:28:11 -04:00
|
|
|
@projects = @projects.in_namespace(params[:namespace_id]) if params[:namespace_id].present?
|
2016-05-26 18:55:49 -04:00
|
|
|
@projects = @projects.where(visibility_level: params[:visibility_level]) if params[:visibility_level].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?
|
2016-04-06 07:47:05 -04:00
|
|
|
@projects = @projects.where(last_repository_check_failed: true) if params[:last_repository_check_failed].present?
|
2016-05-26 18:55:49 -04:00
|
|
|
@projects = @projects.non_archived unless params[:archived].present?
|
|
|
|
@projects = @projects.personal(current_user) if params[:personal].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])
|
2016-03-19 17:37:54 -04:00
|
|
|
@projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page])
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
2014-06-02 14:25:01 -04:00
|
|
|
if @group
|
2016-03-19 17:37:54 -04:00
|
|
|
@group_members = @group.members.order("access_level DESC").page(params[:group_members_page])
|
2014-06-02 14:25:01 -04:00
|
|
|
end
|
|
|
|
|
2016-06-27 10:20:57 -04:00
|
|
|
@project_members = @project.members.page(params[:project_members_page])
|
2016-07-28 13:38:32 -04:00
|
|
|
@requesters = AccessRequestsFinder.new(@project).execute(current_user)
|
2013-11-15 08:25:37 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def transfer
|
2015-07-02 08:31:25 -04:00
|
|
|
namespace = Namespace.find_by(id: params[:new_namespace_id])
|
|
|
|
::Projects::TransferService.new(@project, current_user, params.dup).execute(namespace)
|
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
|
|
|
|
|
2016-04-06 07:47:05 -04:00
|
|
|
def repository_check
|
2016-04-13 09:56:05 -04:00
|
|
|
RepositoryCheck::SingleRepositoryWorker.perform_async(@project.id)
|
2016-04-04 11:23:43 -04:00
|
|
|
|
|
|
|
redirect_to(
|
|
|
|
admin_namespace_project_path(@project.namespace, @project),
|
2016-04-12 12:09:45 -04:00
|
|
|
notice: 'Repository check was triggered.'
|
2016-04-04 11:23:43 -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
|