From 012077923c32894061429028b6e3ce832b1e88b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=B1=E5=91=B1=E5=91=B1?= Date: Thu, 20 Jul 2023 17:22:18 +0800 Subject: [PATCH] update fork --- app/controllers/forks_controller.rb | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/app/controllers/forks_controller.rb b/app/controllers/forks_controller.rb index e20f27efd..0b6b7ce43 100644 --- a/app/controllers/forks_controller.rb +++ b/app/controllers/forks_controller.rb @@ -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!