fix: delete organization tip

This commit is contained in:
yystopf 2021-11-19 14:44:25 +08:00
parent 0885575cc4
commit 1f989d0a37
2 changed files with 10 additions and 4 deletions

View File

@ -46,7 +46,7 @@ class Organizations::OrganizationsController < Organizations::BaseController
@organization.save! @organization.save!
sync_organization_extension! sync_organization_extension!
Gitea::Organization::UpdateService.call(@organization.gitea_token, login, @organization.reload) Gitea::Organization::UpdateService.call(current_user.gitea_token, login, @organization.reload)
Util.write_file(@image, avatar_path(@organization)) if params[:image].present? Util.write_file(@image, avatar_path(@organization)) if params[:image].present?
end end
rescue Exception => e rescue Exception => e
@ -57,10 +57,14 @@ class Organizations::OrganizationsController < Organizations::BaseController
def destroy def destroy
tip_exception("密码不正确") unless current_user.check_password?(password) tip_exception("密码不正确") unless current_user.check_password?(password)
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
Gitea::Organization::DeleteService.call(@organization.gitea_token, @organization.login) gitea_status, gitea_message = Gitea::Organization::DeleteService.call(current_user.gitea_token, @organization.login)
@organization.destroy! if gitea_status == 204
@organization.destroy!
render_ok
else
tip_exception("当组织内含有仓库时,无法删除此组织")
end
end end
render_ok
rescue Exception => e rescue Exception => e
uid_logger_error(e.message) uid_logger_error(e.message)
tip_exception(e.message) tip_exception(e.message)

View File

@ -144,6 +144,8 @@ class Gitea::ClientService < ApplicationService
{status: 403, message: '你没有权限操作!'} {status: 403, message: '你没有权限操作!'}
when 404 when 404
{status: 404, message: '你访问的链接不存在!'} {status: 404, message: '你访问的链接不存在!'}
when 500
{status: 500, message: ''}
else else
if response&.body.blank? if response&.body.blank?
message = "请求失败" message = "请求失败"