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

70 lines
1.8 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2014-09-02 18:07:02 +05:30
class Admin::ProjectsController < Admin::ApplicationController
2018-03-17 18:26:18 +05:30
include MembersPresentation
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
2018-03-17 18:26:18 +05:30
params[:sort] ||= 'latest_activity_desc'
@sort = params[:sort]
@projects = Admin::ProjectsFinder.new(params: params, current_user: current_user).execute
2017-08-17 22:00:37 +05:30
respond_to do |format|
format.html
format.json do
render json: {
2019-05-18 00:54:41 +05:30
html: view_to_html_string("admin/projects/_projects", projects: @projects)
2017-08-17 22:00:37 +05:30
}
end
end
2014-09-02 18:07:02 +05:30
end
2018-12-05 23:21:45 +05:30
# rubocop: disable CodeReuse/ActiveRecord
2014-09-02 18:07:02 +05:30
def show
if @group
2018-03-17 18:26:18 +05:30
@group_members = present_members(
@group.members.order("access_level DESC").page(params[:group_members_page]))
2014-09-02 18:07:02 +05:30
end
2018-03-17 18:26:18 +05:30
@project_members = present_members(
@project.members.page(params[:project_members_page]))
@requesters = present_members(
AccessRequestsFinder.new(@project).execute(current_user))
2014-09-02 18:07:02 +05:30
end
2018-12-05 23:21:45 +05:30
# rubocop: enable CodeReuse/ActiveRecord
2014-09-02 18:07:02 +05:30
2018-12-05 23:21:45 +05:30
# rubocop: disable CodeReuse/ActiveRecord
2014-09-02 18:07:02 +05:30
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
2017-09-10 17:25:29 +05:30
redirect_to admin_project_path(@project)
2014-09-02 18:07:02 +05:30
end
2018-12-05 23:21:45 +05:30
# rubocop: enable CodeReuse/ActiveRecord
2014-09-02 18:07:02 +05:30
2016-06-02 11:05:42 +05:30
def repository_check
RepositoryCheck::SingleRepositoryWorker.perform_async(@project.id)
redirect_to(
2017-09-10 17:25:29 +05:30
admin_project_path(@project),
2019-05-18 00:54:41 +05:30
notice: _('Repository check was triggered.')
2016-06-02 11:05:42 +05:30
)
end
2014-09-02 18:07:02 +05:30
protected
def project
2017-08-17 22:00:37 +05:30
@project = Project.find_by_full_path(
2015-04-26 12:48:37 +05:30
[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