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

58 lines
2 KiB
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
class Admin::ProjectsController < Admin::ApplicationController
2016-06-02 11:05:42 +05:30
before_action :project, only: [:show, :transfer, :repository_check]
2015-09-11 14:41:01 +05:30
before_action :group, 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?
2016-08-24 12:49:21 +05:30
@projects = @projects.where(visibility_level: params[:visibility_level]) if params[:visibility_level].present?
2014-09-02 18:07:02 +05:30
@projects = @projects.with_push if params[:with_push].present?
@projects = @projects.abandoned if params[:abandoned].present?
2016-06-02 11:05:42 +05:30
@projects = @projects.where(last_repository_check_failed: true) if params[:last_repository_check_failed].present?
2016-08-24 12:49:21 +05:30
@projects = @projects.non_archived unless params[:archived].present?
@projects = @projects.personal(current_user) if params[:personal].present?
2014-09-02 18:07:02 +05:30
@projects = @projects.search(params[:name]) if params[:name].present?
@projects = @projects.sort(@sort = params[:sort])
2016-06-02 11:05:42 +05:30
@projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page])
2014-09-02 18:07:02 +05:30
end
def show
if @group
2016-06-02 11:05:42 +05:30
@group_members = @group.members.order("access_level DESC").page(params[:group_members_page])
2014-09-02 18:07:02 +05:30
end
2016-08-24 12:49:21 +05:30
@project_members = @project.members.page(params[:project_members_page])
@requesters = @project.requesters
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
2016-06-02 11:05:42 +05:30
def repository_check
RepositoryCheck::SingleRepositoryWorker.perform_async(@project.id)
redirect_to(
admin_namespace_project_path(@project.namespace, @project),
notice: 'Repository check was triggered.'
)
end
2014-09-02 18:07:02 +05:30
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