|
|
|
@ -2,7 +2,7 @@ class ProjectsController < ApplicationController
|
|
|
|
|
include ApplicationHelper
|
|
|
|
|
include OperateProjectAbilityAble
|
|
|
|
|
before_action :require_login, except: %i[index branches group_type_list]
|
|
|
|
|
before_action :find_project_with_id, only: %i[show branches update]
|
|
|
|
|
before_action :find_project_with_id, only: %i[show branches update destroy]
|
|
|
|
|
before_action :authorizate_user_can_edit_project!, only: %i[update]
|
|
|
|
|
|
|
|
|
|
def index
|
|
|
|
@ -58,6 +58,21 @@ class ProjectsController < ApplicationController
|
|
|
|
|
def show
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
|
if current_user.admin? || @project.owner?(current_user)
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
Gitea::Repository::DeleteService.new(@project.owner, @project.identifier).call
|
|
|
|
|
@project.destroy!
|
|
|
|
|
render_ok
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
render_forbidden('你没有权限操作')
|
|
|
|
|
end
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
uid_logger_error(e.message)
|
|
|
|
|
tip_exception(e.message)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
def project_params
|
|
|
|
|
params.permit(:user_id, :name, :description, :repository_name,
|
|
|
|
|