Merge pull request '调整fork判定写法' (#90) from KingChan/forgeplus:chenjing into standalone_develop

This commit is contained in:
KingChan 2023-07-20 17:24:10 +08:00
commit c58b821b9f
1 changed files with 7 additions and 14 deletions

View File

@ -30,21 +30,14 @@ class ForksController < ApplicationController
@organization = Organization.find_by(login:params[:organization])
return render_forbidden('仓库不存在') unless @organization.present?
return render_forbidden('你没有权限操作') unless @organization.is_admin?(current_user.id)
return render_result(-1, "fork失败组织已拥有了这个项目") if @organization && Project.exists?(user_id: [@organization.id], identifier: (params[:new_identifier] || @project.identifier))
return render_result(-1, "fork失败请联系系统管理员") if gitea_check_exit(@organization)
else
return render_result(-1, "fork失败您已fork过了这个项目") if Project.exists?(user_id: current_user.id, forked_from_project_id: @project.id)
return render_result(-2, "fork失败, fork本人项目需要为fork仓库重命名") if Project.exists?(user_id: current_user.id, identifier: (params[:new_identifier] || @project.identifier))
return render_result(-1, "fork失败请联系系统管理员") if gitea_check_exit(current_user)
end
if Project.exists?(user_id: current_user.id, forked_from_project_id: @project.id)
render_result(-1, "fork失败您已fork过了这个项目")
elsif params[:organization].blank? && Project.exists?(user_id: current_user.id, identifier: (params[:new_identifier] || @project.identifier))
render_result(-2, "fork失败, fork本人项目需要为fork仓库重命名")
elsif @organization && Project.exists?(user_id: [@organization.id], identifier: (params[:new_identifier] || @project.identifier))
render_result(-1, "fork失败组织已拥有了这个项目")
elsif gitea_check_exit(current_user)
render_result(-1, "fork失败请联系系统管理员")
elsif @organization && gitea_check_exit(@organization)
render_result(-1, "fork失败请联系系统管理员")
end
# return if current_user != @project.owner
# render_result(-1, "自己不能fork自己的项目")
end
def authenticate_user!