mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-13 08:15:55 +08:00
Merge branch 'standalone_develop' into pm_project_develop
This commit is contained in:
@@ -43,11 +43,11 @@ class ProjectsController < ApplicationController
|
||||
|
||||
category_id = params[:category_id]
|
||||
@total_count =
|
||||
if category_id.blank? && params[:search].blank? && params[:topic_id].blank?
|
||||
if category_id.blank? && params[:search].blank? && params[:topic_id].blank? && params[:topic_name].blank?
|
||||
# 默认查询时count性能问题处理
|
||||
not_category_count = Project.where(project_category_id: nil).count
|
||||
ProjectCategory.sum("projects_count") - Project.visible.joins("left join organization_extensions on organization_extensions.organization_id = projects.user_id").where("organization_extensions.visibility =2").count + not_category_count
|
||||
elsif params[:search].present? || params[:topic_id].present?
|
||||
elsif params[:search].present? || params[:topic_id].present? || params[:topic_name].present?
|
||||
@projects.total_count
|
||||
else
|
||||
cate = ProjectCategory.find_by(id: category_id)
|
||||
@@ -217,6 +217,10 @@ class ProjectsController < ApplicationController
|
||||
|
||||
new_project_params = project_params.except(:private).merge(is_public: !private)
|
||||
@project.update_attributes!(new_project_params)
|
||||
fork_pull_requests = PullRequest.where(fork_project_id: @project.id)
|
||||
if fork_pull_requests.present?
|
||||
fork_pull_requests.update_all(fork_project_identifier: @project.identifier)
|
||||
end
|
||||
@project.forked_projects.map{|p| p.update!(is_public: @project.is_public)}
|
||||
gitea_params = {
|
||||
private: private,
|
||||
@@ -249,6 +253,7 @@ class ProjectsController < ApplicationController
|
||||
def destroy
|
||||
if current_user.admin? || @project.manager?(current_user)
|
||||
ActiveRecord::Base.transaction do
|
||||
close_fork_pull_requests_by(@project)
|
||||
Gitea::Repository::DeleteService.new(@project.owner, @project.identifier,current_user.gitea_token).call
|
||||
@project.destroy!
|
||||
@project.forked_projects.update_all(forked_from_project_id: nil)
|
||||
@@ -381,7 +386,7 @@ class ProjectsController < ApplicationController
|
||||
end
|
||||
|
||||
def mirror_params
|
||||
params.permit(:user_id, :name, :description, :repository_name, :is_mirror, :auth_username, :auth_token,
|
||||
params.permit(:user_id, :name, :description, :repository_name, :is_mirror, :auth_username, :auth_token, :service,
|
||||
:auth_password, :project_category_id, :project_language_id, :clone_addr, :private)
|
||||
end
|
||||
|
||||
@@ -399,4 +404,19 @@ class ProjectsController < ApplicationController
|
||||
render_unauthorized('你还未登录.')
|
||||
end
|
||||
end
|
||||
|
||||
def close_fork_pull_requests_by(project)
|
||||
open_pull_requests = PullRequest.where(fork_project_id: project.id)
|
||||
if open_pull_requests.present?
|
||||
open_pull_requests.each do |pull_request|
|
||||
closed = PullRequests::CloseService.call(pull_request&.project.owner, pull_request&.project.repository, pull_request, current_user)
|
||||
if closed === true
|
||||
pull_request.project_trends.create!(user: current_user, project: pull_request&.project,action_type: ProjectTrend::CLOSE)
|
||||
# 合并请求下issue处理为关闭
|
||||
pull_request.issue&.update_attributes!({status_id:5})
|
||||
SendTemplateMessageJob.perform_later('PullRequestClosed', current_user.id, pull_request.id) if Site.has_notice_menu?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user