Browse Source

fix: delete organization tip

tags/v4.0.0^2
yystopf 4 years ago
parent
commit
1f989d0a37
2 changed files with 10 additions and 4 deletions
  1. +8
    -4
      app/controllers/organizations/organizations_controller.rb
  2. +2
    -0
      app/services/gitea/client_service.rb

+ 8
- 4
app/controllers/organizations/organizations_controller.rb View File

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


+ 2
- 0
app/services/gitea/client_service.rb View File

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


Loading…
Cancel
Save