From b51f31cb6b5c1ca8c8fe6768c8762b8ba06cd45d Mon Sep 17 00:00:00 2001 From: xxq250 Date: Tue, 24 Sep 2024 11:48:05 +0800 Subject: [PATCH 01/75] =?UTF-8?q?fixed=20=E5=A4=9A=E6=B5=8F=E8=A7=88?= =?UTF-8?q?=E5=99=A8=E9=80=80=E5=87=BA=E8=B4=A6=E5=8F=B7=E6=97=B6=EF=BC=8C?= =?UTF-8?q?token=E4=B8=8D=E5=AD=98=E5=9C=A8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 52387cbbd..d9dd9e2e6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -376,7 +376,7 @@ class ApplicationController < ActionController::Base # 多浏览器退出账号时,token不存在处理 if current_domain_session && autologin_user.nil? autologin_user = (User.active.find(current_domain_session) rescue nil) - set_autologin_cookie(autologin_user) + set_autologin_cookie(autologin_user) if autologin_user.present? end autologin_user end From 484346d5428d42b2fb6215694698dec884d1efc4 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Tue, 24 Sep 2024 16:28:58 +0800 Subject: [PATCH 02/75] =?UTF-8?q?fixed=20=E8=B4=A6=E5=8F=B7=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=96=B9=E6=B3=95=E5=A2=9E=E5=8A=A0=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/accounts_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 14d59af77..99bc19fda 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -1,5 +1,5 @@ class AccountsController < ApplicationController - before_action :require_login, only: [:login_check, :simple_update] + before_action :require_login, only: [:login_check, :simple_update, :change_password] include ApplicationHelper #skip_before_action :check_account, :only => [:logout] From ca226e1f8100b58b7da4022c0842a5f31f6759b0 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Tue, 24 Sep 2024 16:34:05 +0800 Subject: [PATCH 03/75] =?UTF-8?q?fixed=20=E8=B4=A6=E5=8F=B7=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=96=B9=E6=B3=95=E5=A2=9E=E5=8A=A0=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=AA=8C=E8=AF=81,=E5=AE=89=E5=85=A8=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/accounts_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 99bc19fda..e0508efe8 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -224,6 +224,7 @@ class AccountsController < ApplicationController def change_password return render_error("两次输入的密码不一致") if params[:password].to_s != params[:new_password_repeat].to_s @user = User.find_by(login: params[:login]) + return render_forbidden unless User.current.login == @user&.login return render_error("此用户禁止修改密码!") if @user.id.to_i === 104691 return render_error("未找到相关用户!") if @user.blank? return render_error("旧密码不正确") unless @user.check_password?(params[:old_password]) From 5c3a9883364aeac59a78dc30695cef5a267e3a58 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Tue, 24 Sep 2024 17:10:45 +0800 Subject: [PATCH 04/75] =?UTF-8?q?fixed=20=E6=A3=80=E6=B5=8B=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=B8=8D=E5=AD=98=E5=9C=A8=E6=97=B6=E6=B8=85=E9=99=A4?= =?UTF-8?q?cookie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/concerns/login_helper.rb | 8 ++++++++ app/controllers/owners_controller.rb | 1 + 2 files changed, 9 insertions(+) diff --git a/app/controllers/concerns/login_helper.rb b/app/controllers/concerns/login_helper.rb index c0e8d01c0..3aec09126 100644 --- a/app/controllers/concerns/login_helper.rb +++ b/app/controllers/concerns/login_helper.rb @@ -73,6 +73,14 @@ module LoginHelper session[:"#{default_yun_session}"] = nil end + def clear_user_cookie + if edu_setting('cookie_domain').present? + cookies.delete(autologin_cookie_name, domain: edu_setting('cookie_domain')) + else + cookies.delete(autologin_cookie_name) + end + end + # Sets the logged in user def logged_user=(user) reset_session diff --git a/app/controllers/owners_controller.rb b/app/controllers/owners_controller.rb index 28a5210d5..eadbdbf95 100644 --- a/app/controllers/owners_controller.rb +++ b/app/controllers/owners_controller.rb @@ -12,6 +12,7 @@ class OwnersController < ApplicationController def show @owner = Owner.find_by(login: params[:id]) || Owner.find_by(id: params[:id]) + clear_user_cookie unless @owner.present? return render_not_found unless @owner.present? # 组织 if @owner.is_a?(Organization) From 30ec8ef1ce3c78da6a666628c77f0dc5e383959b Mon Sep 17 00:00:00 2001 From: xxq250 Date: Tue, 24 Sep 2024 17:13:01 +0800 Subject: [PATCH 05/75] =?UTF-8?q?fixed=20=E6=A3=80=E6=B5=8B=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=B8=8D=E5=AD=98=E5=9C=A8=E6=97=B6=E6=B8=85=E9=99=A4?= =?UTF-8?q?cookie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/concerns/login_helper.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/concerns/login_helper.rb b/app/controllers/concerns/login_helper.rb index 3aec09126..3abb82e23 100644 --- a/app/controllers/concerns/login_helper.rb +++ b/app/controllers/concerns/login_helper.rb @@ -79,6 +79,8 @@ module LoginHelper else cookies.delete(autologin_cookie_name) end + # 清除前端写入的用户名 + cookies.delete("login") end # Sets the logged in user From 2148d5a0cec1b98d388137251ad5842ecddb3613 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Tue, 24 Sep 2024 17:17:03 +0800 Subject: [PATCH 06/75] =?UTF-8?q?fixed=20=E6=A3=80=E6=B5=8B=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=B8=8D=E5=AD=98=E5=9C=A8=E6=97=B6=E6=B8=85=E9=99=A4?= =?UTF-8?q?cookie=20log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/concerns/login_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/concerns/login_helper.rb b/app/controllers/concerns/login_helper.rb index 3abb82e23..c3b3ecc92 100644 --- a/app/controllers/concerns/login_helper.rb +++ b/app/controllers/concerns/login_helper.rb @@ -80,6 +80,7 @@ module LoginHelper cookies.delete(autologin_cookie_name) end # 清除前端写入的用户名 + Rails.logger.info("########________cookies['login']___________###########{cookies['login']}") cookies.delete("login") end From 2faea9aa591abfe0303a3753c812f189ae22f703 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 25 Sep 2024 11:40:13 +0800 Subject: [PATCH 07/75] =?UTF-8?q?fixed=20=E7=94=A8=E6=88=B7=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E4=BC=98=E5=8C=96=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admins/users_controller.rb | 13 +++++++++++++ app/services/gitea/user/delete_service.rb | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/controllers/admins/users_controller.rb b/app/controllers/admins/users_controller.rb index e544cfb8e..8d22006f6 100644 --- a/app/controllers/admins/users_controller.rb +++ b/app/controllers/admins/users_controller.rb @@ -27,6 +27,19 @@ class Admins::UsersController < Admins::BaseController def destroy UserAction.create(action_id: @user.id, action_type: "DestroyUser", user_id: current_user.id, :ip => request.remote_ip, data_bank: @user.attributes.to_json) + org_ids = TeamUser.where(user_id: @user.id).pluck(:organization_id) | OrganizationUser..where(user_id: @user.id).pluck(:organization_id) + organizations = Organization.where(id: org_ids) + organizations.each do |org| + # org.team_users.joins(:team).where(user_id: @user.id, teams: {authorize: %w(owner)}) + org.team_users.joins(:team).where(teams: {authorize: %w(owner)}) + # 多个owner时,仅将用户从组织移除, 一个时直接删除 + if org.count > 1 + org.team_users.joins(:team).where(user_id: @user.id, teams: {authorize: %w(owner)}).destroy_all + org.organization_users.where(user_id: @user.id, organization_id: org.id).destroy_all + else + org.destroy + end + end @user.destroy! Gitea::User::DeleteService.call(@user.login) diff --git a/app/services/gitea/user/delete_service.rb b/app/services/gitea/user/delete_service.rb index 9011158d2..d70c51575 100644 --- a/app/services/gitea/user/delete_service.rb +++ b/app/services/gitea/user/delete_service.rb @@ -6,7 +6,7 @@ class Gitea::User::DeleteService < Gitea::ClientService end def call - response = delete(request_url, params) + response = delete(request_url, params.merge(purge: true)) render_status(response) end From 5f3aaa03eb19509a7680c15dc61408e5c71c149a Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 25 Sep 2024 11:43:43 +0800 Subject: [PATCH 08/75] =?UTF-8?q?fixed=20=E7=94=A8=E6=88=B7=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E4=BC=98=E5=8C=96=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admins/users_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/admins/users_controller.rb b/app/controllers/admins/users_controller.rb index 8d22006f6..09ef06ffe 100644 --- a/app/controllers/admins/users_controller.rb +++ b/app/controllers/admins/users_controller.rb @@ -27,7 +27,7 @@ class Admins::UsersController < Admins::BaseController def destroy UserAction.create(action_id: @user.id, action_type: "DestroyUser", user_id: current_user.id, :ip => request.remote_ip, data_bank: @user.attributes.to_json) - org_ids = TeamUser.where(user_id: @user.id).pluck(:organization_id) | OrganizationUser..where(user_id: @user.id).pluck(:organization_id) + org_ids = TeamUser.where(user_id: @user.id).pluck(:organization_id) | OrganizationUser.where(user_id: @user.id).pluck(:organization_id) organizations = Organization.where(id: org_ids) organizations.each do |org| # org.team_users.joins(:team).where(user_id: @user.id, teams: {authorize: %w(owner)}) From d1968a63c10b293f6ae96a80b33afb0d0ed8806b Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 25 Sep 2024 11:47:15 +0800 Subject: [PATCH 09/75] =?UTF-8?q?fixed=20=E7=94=A8=E6=88=B7=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E4=BC=98=E5=8C=96=E5=A4=84=E7=90=86,=E5=A4=9A?= =?UTF-8?q?=E4=B8=AAowner=E6=97=B6,=E4=BB=85=E5=B0=86=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BB=8E=E7=BB=84=E7=BB=87=E7=A7=BB=E9=99=A4,=20=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E6=97=B6=E7=9B=B4=E6=8E=A5=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admins/users_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/admins/users_controller.rb b/app/controllers/admins/users_controller.rb index 09ef06ffe..ba7b70d29 100644 --- a/app/controllers/admins/users_controller.rb +++ b/app/controllers/admins/users_controller.rb @@ -31,9 +31,9 @@ class Admins::UsersController < Admins::BaseController organizations = Organization.where(id: org_ids) organizations.each do |org| # org.team_users.joins(:team).where(user_id: @user.id, teams: {authorize: %w(owner)}) - org.team_users.joins(:team).where(teams: {authorize: %w(owner)}) + owner_count = org.team_users.joins(:team).where(teams: {authorize: %w(owner)}).count # 多个owner时,仅将用户从组织移除, 一个时直接删除 - if org.count > 1 + if owner_count > 1 org.team_users.joins(:team).where(user_id: @user.id, teams: {authorize: %w(owner)}).destroy_all org.organization_users.where(user_id: @user.id, organization_id: org.id).destroy_all else From e29b6181bc9d5898842d85c73f9304a35cdce5e8 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 25 Sep 2024 11:50:55 +0800 Subject: [PATCH 10/75] =?UTF-8?q?fixed=20=E7=94=A8=E6=88=B7=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E4=BC=98=E5=8C=96=E5=A4=84=E7=90=86,=E5=A4=9A?= =?UTF-8?q?=E4=B8=AAowner=E6=97=B6,=E4=BB=85=E5=B0=86=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BB=8E=E7=BB=84=E7=BB=87=E7=A7=BB=E9=99=A4,=20=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E6=97=B6=E7=9B=B4=E6=8E=A5=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/gitea/user/delete_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/gitea/user/delete_service.rb b/app/services/gitea/user/delete_service.rb index d70c51575..763c6047f 100644 --- a/app/services/gitea/user/delete_service.rb +++ b/app/services/gitea/user/delete_service.rb @@ -6,7 +6,7 @@ class Gitea::User::DeleteService < Gitea::ClientService end def call - response = delete(request_url, params.merge(purge: true)) + response = delete(request_url, params.merge(data: {purge: true})) render_status(response) end From 3b5894894fcd74347f43c51fe0d2e209c7e0e897 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 25 Sep 2024 14:01:37 +0800 Subject: [PATCH 11/75] =?UTF-8?q?fixed=20=E7=94=A8=E6=88=B7=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E4=BC=98=E5=8C=96=E5=A4=84=E7=90=86,=E5=A4=9A?= =?UTF-8?q?=E4=B8=AAowner=E6=97=B6,=E4=BB=85=E5=B0=86=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BB=8E=E7=BB=84=E7=BB=87=E7=A7=BB=E9=99=A4,=20=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E6=97=B6=E7=9B=B4=E6=8E=A5=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admins/users_controller.rb | 2 +- app/services/gitea/user/delete_service.rb | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/admins/users_controller.rb b/app/controllers/admins/users_controller.rb index ba7b70d29..f5974b47d 100644 --- a/app/controllers/admins/users_controller.rb +++ b/app/controllers/admins/users_controller.rb @@ -41,7 +41,7 @@ class Admins::UsersController < Admins::BaseController end end @user.destroy! - Gitea::User::DeleteService.call(@user.login) + Gitea::User::DeleteService.call(@user.login, true) render_delete_success end diff --git a/app/services/gitea/user/delete_service.rb b/app/services/gitea/user/delete_service.rb index 763c6047f..096a88251 100644 --- a/app/services/gitea/user/delete_service.rb +++ b/app/services/gitea/user/delete_service.rb @@ -1,12 +1,13 @@ class Gitea::User::DeleteService < Gitea::ClientService - attr_reader :username + attr_reader :username, purge - def initialize(username) + def initialize(username, purge = false) @username = username + @purge = purge end def call - response = delete(request_url, params.merge(data: {purge: true})) + response = delete(request_url, params) render_status(response) end @@ -20,7 +21,7 @@ class Gitea::User::DeleteService < Gitea::ClientService end def request_url - "/admin/users/#{username}" + @purge ? "/admin/users/#{username}?purge=true" : "/admin/users/#{username}" end def params From 3cce800746f7f17d151e45900056998afb08bf5c Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 25 Sep 2024 14:03:09 +0800 Subject: [PATCH 12/75] =?UTF-8?q?fixed=20=E7=94=A8=E6=88=B7=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E4=BC=98=E5=8C=96=E5=A4=84=E7=90=86,=E5=A4=9A?= =?UTF-8?q?=E4=B8=AAowner=E6=97=B6,=E4=BB=85=E5=B0=86=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BB=8E=E7=BB=84=E7=BB=87=E7=A7=BB=E9=99=A4,=20=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E6=97=B6=E7=9B=B4=E6=8E=A5=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/gitea/user/delete_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/gitea/user/delete_service.rb b/app/services/gitea/user/delete_service.rb index 096a88251..ce357e3d5 100644 --- a/app/services/gitea/user/delete_service.rb +++ b/app/services/gitea/user/delete_service.rb @@ -1,5 +1,5 @@ class Gitea::User::DeleteService < Gitea::ClientService - attr_reader :username, purge + attr_reader :username, :purge def initialize(username, purge = false) @username = username From 75153cb099b166b2e21af1dc5a2f2be3e75dfe9c Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 25 Sep 2024 15:40:53 +0800 Subject: [PATCH 13/75] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admins/users_controller.rb | 39 +++++++++++-------- app/controllers/api/v1/users_controller.rb | 24 ++++++++++++ .../api/v1/users/delete_user_service.rb | 31 +++++++++++++++ config/routes/api.rb | 1 + 4 files changed, 79 insertions(+), 16 deletions(-) create mode 100644 app/services/api/v1/users/delete_user_service.rb diff --git a/app/controllers/admins/users_controller.rb b/app/controllers/admins/users_controller.rb index f5974b47d..f552c9cd1 100644 --- a/app/controllers/admins/users_controller.rb +++ b/app/controllers/admins/users_controller.rb @@ -27,23 +27,30 @@ class Admins::UsersController < Admins::BaseController def destroy UserAction.create(action_id: @user.id, action_type: "DestroyUser", user_id: current_user.id, :ip => request.remote_ip, data_bank: @user.attributes.to_json) - org_ids = TeamUser.where(user_id: @user.id).pluck(:organization_id) | OrganizationUser.where(user_id: @user.id).pluck(:organization_id) - organizations = Organization.where(id: org_ids) - organizations.each do |org| - # org.team_users.joins(:team).where(user_id: @user.id, teams: {authorize: %w(owner)}) - owner_count = org.team_users.joins(:team).where(teams: {authorize: %w(owner)}).count - # 多个owner时,仅将用户从组织移除, 一个时直接删除 - if owner_count > 1 - org.team_users.joins(:team).where(user_id: @user.id, teams: {authorize: %w(owner)}).destroy_all - org.organization_users.where(user_id: @user.id, organization_id: org.id).destroy_all - else - org.destroy - end + # org_ids = TeamUser.where(user_id: @user.id).pluck(:organization_id) | OrganizationUser.where(user_id: @user.id).pluck(:organization_id) + # organizations = Organization.where(id: org_ids) + # organizations.each do |org| + # # org.team_users.joins(:team).where(user_id: @user.id, teams: {authorize: %w(owner)}) + # owner_count = org.team_users.joins(:team).where(teams: {authorize: %w(owner)}).count + # # 多个owner时,仅将用户从组织移除, 一个时直接删除 + # if owner_count > 1 + # org.team_users.joins(:team).where(user_id: @user.id, teams: {authorize: %w(owner)}).destroy_all + # org.organization_users.where(user_id: @user.id, organization_id: org.id).destroy_all + # else + # org.destroy + # end + # end + # @user.destroy! + # Gitea::User::DeleteService.call(@user.login, true) + # + # render_delete_success + + @result_object = Api::V1::Users::DeleteUserService.call(@user) + if @result_object + render_delete_success + else + render_js_error('删除失败!') end - @user.destroy! - Gitea::User::DeleteService.call(@user.login, true) - - render_delete_success end def lock diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index 47087c523..8127c557c 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -115,4 +115,28 @@ class Api::V1::UsersController < Api::V1::BaseController return render_error('更改手机号失败!') end end + + + def check_user_can_delete + org_ids = TeamUser.where(user_id: @observe_user.id).pluck(:organization_id) | OrganizationUser.where(user_id: @observe_user.id).pluck(:organization_id) + org_count = Organization.where(id: org_ids).count + project_count = Project.where(user_id: @observe_user.id).count + render_ok({ org_count: org_count, project_count: project_count }) + end + + + def destroy + return tip_exception(-1, "密码不正确.") unless @observe_user.check_password?(params[:password]) + org_ids = TeamUser.where(user_id: @observe_user.id).pluck(:organization_id) | OrganizationUser.where(user_id: @observe_user.id).pluck(:organization_id) + org_count = Organization.where(id: org_ids).count + project_count = Project.where(user_id: @observe_user.id).count + return tip_exception(-1, "当前账号名下存在未删除或退出的组织/仓库,请先删除或退出后再尝试注销操作.") if org_count > 0 || project_count > 0 + UserAction.create(action_id: @user.id, action_type: "DestroyUser", user_id: nil, :ip => request.remote_ip, data_bank: @user.attributes.to_json) + @result_object = Api::V1::Users::DeleteUserService.call(@observe_user) + if @result_object + return render_ok + else + return render_error('删除失败!') + end + end end \ No newline at end of file diff --git a/app/services/api/v1/users/delete_user_service.rb b/app/services/api/v1/users/delete_user_service.rb new file mode 100644 index 000000000..67714de06 --- /dev/null +++ b/app/services/api/v1/users/delete_user_service.rb @@ -0,0 +1,31 @@ +class Api::V1::Users::DeleteUserService < ApplicationService + attr_reader :user + def initialize(user) + @user = user + end + + def call + begin + ActiveRecord::Base.transaction do + org_ids = TeamUser.where(user_id: @user.id).pluck(:organization_id) | OrganizationUser.where(user_id: @user.id).pluck(:organization_id) + organizations = Organization.where(id: org_ids) + organizations.each do |org| + # org.team_users.joins(:team).where(user_id: @user.id, teams: {authorize: %w(owner)}) + owner_count = org.team_users.joins(:team).where(teams: {authorize: %w(owner)}).count + # 多个owner时,仅将用户从组织移除, 一个时直接删除 + if owner_count > 1 + org.team_users.joins(:team).where(user_id: @user.id, teams: {authorize: %w(owner)}).destroy_all + org.organization_users.where(user_id: @user.id, organization_id: org.id).destroy_all + else + org.destroy + end + end + @user.destroy! + Gitea::User::DeleteService.call(@user.login, true) + end + return true + rescue + raise Error, "服务器错误,请联系系统管理员!" + end + end +end \ No newline at end of file diff --git a/config/routes/api.rb b/config/routes/api.rb index 945a1dc29..91900545b 100644 --- a/config/routes/api.rb +++ b/config/routes/api.rb @@ -58,6 +58,7 @@ defaults format: :json do post :check_email post :check_email_verify_code post :check_phone_verify_code + post :check_user_can_delete patch :update_email patch :update_phone end From 59065ae1e90cc74e2dfbecb2c2065ec43e841296 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 25 Sep 2024 16:11:49 +0800 Subject: [PATCH 14/75] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/users_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index 8127c557c..94c3c69a5 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -131,7 +131,7 @@ class Api::V1::UsersController < Api::V1::BaseController org_count = Organization.where(id: org_ids).count project_count = Project.where(user_id: @observe_user.id).count return tip_exception(-1, "当前账号名下存在未删除或退出的组织/仓库,请先删除或退出后再尝试注销操作.") if org_count > 0 || project_count > 0 - UserAction.create(action_id: @user.id, action_type: "DestroyUser", user_id: nil, :ip => request.remote_ip, data_bank: @user.attributes.to_json) + UserAction.create(action_id: @observe_user.id, action_type: "DestroyUser", user_id: nil, :ip => request.remote_ip, data_bank: @observe_user.attributes.to_json) @result_object = Api::V1::Users::DeleteUserService.call(@observe_user) if @result_object return render_ok From 9954a5f92fe0947d41133d781d90790653ee7d9c Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 25 Sep 2024 16:12:24 +0800 Subject: [PATCH 15/75] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/users_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index 94c3c69a5..721e8505a 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -131,7 +131,7 @@ class Api::V1::UsersController < Api::V1::BaseController org_count = Organization.where(id: org_ids).count project_count = Project.where(user_id: @observe_user.id).count return tip_exception(-1, "当前账号名下存在未删除或退出的组织/仓库,请先删除或退出后再尝试注销操作.") if org_count > 0 || project_count > 0 - UserAction.create(action_id: @observe_user.id, action_type: "DestroyUser", user_id: nil, :ip => request.remote_ip, data_bank: @observe_user.attributes.to_json) + UserAction.create(action_id: @observe_user.id, action_type: "DestroyUser", user_id: @observe_user.id, :ip => request.remote_ip, data_bank: @observe_user.attributes.to_json) @result_object = Api::V1::Users::DeleteUserService.call(@observe_user) if @result_object return render_ok From 610db14bc9f0c6b57c4c44b22bab62b74317d8cf Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 25 Sep 2024 16:21:33 +0800 Subject: [PATCH 16/75] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=A3=80=E6=B5=8B=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/users_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index 721e8505a..e8b064e9a 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -121,7 +121,7 @@ class Api::V1::UsersController < Api::V1::BaseController org_ids = TeamUser.where(user_id: @observe_user.id).pluck(:organization_id) | OrganizationUser.where(user_id: @observe_user.id).pluck(:organization_id) org_count = Organization.where(id: org_ids).count project_count = Project.where(user_id: @observe_user.id).count - render_ok({ org_count: org_count, project_count: project_count }) + render_ok({ can_delete: org_count == 0 && project_count == 0, org_count: org_count, project_count: project_count }) end From 20543c6bc27fd018f7f6c9ef8f7c6d87e8b73e3b Mon Sep 17 00:00:00 2001 From: xxq250 Date: Thu, 26 Sep 2024 13:54:19 +0800 Subject: [PATCH 17/75] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=BB=BA=E6=9C=A8ci?= =?UTF-8?q?=E6=BF=80=E6=B4=BB=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/projects_helper.rb | 2 +- app/jobs/open_project_dev_ops_job.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 0f34b7c1b..80cfa92e0 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -129,7 +129,7 @@ module ProjectsHelper end def jianmu_devops_url - EduSetting.get("jianmu_devops_url") || "https://ci-v3.test.jianmuhub.com" + EduSetting.get("jianmu_devops_url") end diff --git a/app/jobs/open_project_dev_ops_job.rb b/app/jobs/open_project_dev_ops_job.rb index b3fe99e6f..c5d68a861 100644 --- a/app/jobs/open_project_dev_ops_job.rb +++ b/app/jobs/open_project_dev_ops_job.rb @@ -6,6 +6,7 @@ class OpenProjectDevOpsJob < ApplicationJob def perform(project_id, user_id) project = Project.find_by(id: project_id) return if project.blank? + return if EduSetting.get("jianmu_devops_url").blank? user = User.find_by(id: user_id) code = jianmu_devops_code(project, user) uri = URI.parse("#{jianmu_devops_url}/activate?code=#{URI.encode_www_form_component(code)}") From 7f4bb60b5e79239a3408cf8d74d9f900ca268d8e Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 26 Sep 2024 17:00:17 +0800 Subject: [PATCH 18/75] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E6=97=A5=E5=BF=97=E5=85=BC=E5=AE=B9=E6=97=A7issue?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/api/v1/issues/journals/_detail.json.jbuilder | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/api/v1/issues/journals/_detail.json.jbuilder b/app/views/api/v1/issues/journals/_detail.json.jbuilder index 21040bc0a..b033579f8 100644 --- a/app/views/api/v1/issues/journals/_detail.json.jbuilder +++ b/app/views/api/v1/issues/journals/_detail.json.jbuilder @@ -11,8 +11,8 @@ json.user do end if journal.is_journal_detail? detail = journal.journal_details.take - json.operate_category detail.property == "attr" ? detail.prop_key : detail.property - json.operate_content journal.is_journal_detail? ? journal.operate_content : nil + json.operate_category @issue.pm_issue_type.nil? ? detail.property == "attr" ? detail.prop_key : detail.property : journal.pm_operate_category + json.operate_content journal.is_journal_detail? ? @issue.pm_issue_type.nil? ? journal.operate_content : journal.pm_operate_content : nil else json.notes journal.notes json.comments_count journal.comments_count From 47f8ce478cb60d75d39000d6e8727b4734ad4b39 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 27 Sep 2024 09:35:40 +0800 Subject: [PATCH 19/75] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admins/user_actions_controller.rb | 14 +++++ app/models/user_action.rb | 54 ++++++++++++++++++- .../user_actions/_user_action_list.html.erb | 44 +++++++++++++++ app/views/admins/user_actions/index.html.erb | 50 +++++++++++++++++ app/views/admins/user_actions/index.js.erb | 1 + config/routes.rb | 3 +- ...926031029_add_user_info_to_user_actions.rb | 20 +++++++ 7 files changed, 183 insertions(+), 3 deletions(-) create mode 100644 app/controllers/admins/user_actions_controller.rb create mode 100644 app/views/admins/user_actions/_user_action_list.html.erb create mode 100644 app/views/admins/user_actions/index.html.erb create mode 100644 app/views/admins/user_actions/index.js.erb create mode 100644 db/migrate/202410926031029_add_user_info_to_user_actions.rb diff --git a/app/controllers/admins/user_actions_controller.rb b/app/controllers/admins/user_actions_controller.rb new file mode 100644 index 000000000..d96cdc97e --- /dev/null +++ b/app/controllers/admins/user_actions_controller.rb @@ -0,0 +1,14 @@ +class Admins::UserActionsController < Admins::BaseController + before_action :require_admin + + def index + @user_actions = UserAction.order(created_at: :desc) + @user_actions = @user_actions.where(action_type: params[:action_type]) if params[:action_type].present? + keyword = params[:keyword].to_s.strip.presence + if keyword + sql = 'login LIKE :keyword OR phone LIKE :keyword OR mail LIKE :keyword' + @user_actions = @user_actions.where(sql, keyword: "%#{keyword}%") + end + @user_actions = paginate @user_actions + end +end diff --git a/app/models/user_action.rb b/app/models/user_action.rb index b4173fe77..7405c0c44 100644 --- a/app/models/user_action.rb +++ b/app/models/user_action.rb @@ -10,6 +10,10 @@ # updated_at :datetime not null # ip :string(255) # data_bank :text(65535) +# login :string(255) +# phone :string(255) +# email :string(255) +# memo :text(65535) # # Indexes # @@ -19,5 +23,51 @@ # index_user_actions_on_user_id (user_id) # -class UserAction < ApplicationRecord -end +class UserAction < ApplicationRecord + + before_create :add_user_info + + serialize :data_bank, JSON + + def action_name + case action_type + when "DestroyUser" then "删除用户" + when "DestroyProject" then "删除项目" + when "Login" then "登录" + when "Logout" then "退出登录" + else self.action_type + end + end + + def action_data + case action_type + when "DestroyUser" then build_mode("User") + when "DestroyProject" then build_mode("Project") + else nil + end + end + + def user + action_user = User.find_by(id: self.user_id) + if action_user.blank? + action_user = self.action_data + end + action_user + end + def build_mode(model_name) + model = model_name.constantize.new + model_name.constantize.column_names.each do |col| + model[col] = self.data_bank[col] + end + model + end + + private + def add_user_info + if user.present? + self.login = user.login + self.email = user.mail + self.phone = user.phone + end + end +end diff --git a/app/views/admins/user_actions/_user_action_list.html.erb b/app/views/admins/user_actions/_user_action_list.html.erb new file mode 100644 index 000000000..8577b2f29 --- /dev/null +++ b/app/views/admins/user_actions/_user_action_list.html.erb @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + <% if user_actions.present? %> + <% user_actions.each_with_index do |action, index| %> + + + + + + + + + + + <% end %> + <% else %> + <%= render 'admins/shared/no_data_for_table' %> + <% end %> + +
序号操作类型账号邮箱手机号姓名操作时间原因/备注
<%= list_index_no((params[:page] || 1).to_i, index) %><%= action.action_name %> + <%= link_to "/#{action.user&.login}", target: '_blank' do %> + <%= overflow_hidden_span action.user&.login, width: 100 %> + <% end %> + + <%= overflow_hidden_span action.user&.mail, width: 150 %> + <%= action.user&.phone %> + <%= link_to "/#{action.user&.login}", target: '_blank' do %> + <%= overflow_hidden_span action.user&.real_name, width: 100 %> + <% end %> + <%= display_text(action.created_at&.strftime('%Y-%m-%d %H:%M')) %><%= action.memo %>
+ +<%= render partial: 'admins/shared/paginate', locals: { objects: user_actions } %> diff --git a/app/views/admins/user_actions/index.html.erb b/app/views/admins/user_actions/index.html.erb new file mode 100644 index 000000000..8821a8be0 --- /dev/null +++ b/app/views/admins/user_actions/index.html.erb @@ -0,0 +1,50 @@ +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb('操作记录', admins_user_actions_path) %> +<% end %> + +
+ <%= form_tag(admins_user_actions_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %> + 操作类型: + <% action_type_options = [['自定义',''],['删除用户','DestroyUser'], ['删除项目', 'DestroyProject']] %> + <%= select_tag(:action_type_select, options_for_select(action_type_options), class: 'form-control') %> + <%= text_field_tag(:action_type, params[:action_type], class: 'form-control col-sm-2 ml-3',style: 'display:none;', placeholder: '自定义操作类型检索') %> + <%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: '用户名/邮箱/手机号检索') %> + <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> + <% end %> + +
+ + + + + + <%# @user_nps_mid = @score_total_count % 2 == 0 ? @score_total_count / 2 : (@score_total_count + 1) / 2 %> + + + + + + + + + + + + +
+ <%= render partial: 'admins/user_actions/user_action_list', locals: { user_actions: @user_actions } %> +
+ + diff --git a/app/views/admins/user_actions/index.js.erb b/app/views/admins/user_actions/index.js.erb new file mode 100644 index 000000000..d624a61ae --- /dev/null +++ b/app/views/admins/user_actions/index.js.erb @@ -0,0 +1 @@ +$('.users-list-container').html("<%= j( render partial: 'admins/user_actions/user_action_list', locals: { user_actions: @user_actions } ) %>"); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 64d064b86..501a024b4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -92,7 +92,7 @@ Rails.application.routes.draw do resources :project_rank, only: [:index] resources :user_rank, only: [:index] resources :nps, only: [:create] - + resources :statistic, only: [:index] do collection do get :platform_profile @@ -1025,6 +1025,7 @@ Rails.application.routes.draw do post :drag, on: :collection post :replace_image_url, on: :member end + resources :user_actions , only:[:index] resources :faqs resources :nps do post :switch_change, on: :collection diff --git a/db/migrate/202410926031029_add_user_info_to_user_actions.rb b/db/migrate/202410926031029_add_user_info_to_user_actions.rb new file mode 100644 index 000000000..e361d2b1d --- /dev/null +++ b/db/migrate/202410926031029_add_user_info_to_user_actions.rb @@ -0,0 +1,20 @@ +class AddUserInfoToUserActions < ActiveRecord::Migration[5.2] + def change + add_column :user_actions, :login, :string + add_column :user_actions, :phone, :string + add_column :user_actions, :email, :string + add_column :user_actions, :memo, :text + + UserAction.find_in_batches(batch_size: 1000) do |sw| + Parallel.each(sw, in_threads: 5) do |user_action| + next if user_action.user_id.blank? + user = User.find_by(id: user_action.user_id) + next if user.blank? + user_action.login = user.login + user_action.email = user.mail + user_action.phone = user.phone + user_action.save + end + end + end +end From 2381851c88a3c69ae9fcf7a7a5ef21db00b6b5e0 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 27 Sep 2024 09:44:06 +0800 Subject: [PATCH 20/75] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E6=9F=A5=E8=AF=A2=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/admins/shared/_sidebar.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/admins/shared/_sidebar.html.erb b/app/views/admins/shared/_sidebar.html.erb index 7919b12d0..d48db392d 100644 --- a/app/views/admins/shared/_sidebar.html.erb +++ b/app/views/admins/shared/_sidebar.html.erb @@ -26,6 +26,7 @@
  • <%= sidebar_item(admins_faqs_path, 'FAQ', icon: 'question-circle', controller: 'admins-faqs', has_permission: current_user.admin? || current_user.business?) %>
  • <%= sidebar_item(admins_nps_path, 'NPS用户调研', icon: 'question-circle', controller: 'admins-nps', has_permission: current_user.admin? || current_user.business?) %>
  • <%= sidebar_item(admins_feedbacks_path, '用户反馈', icon: 'question-circle', controller: 'admins-feedbacks', has_permission: current_user.admin? || current_user.business?) %>
  • +
  • <%= sidebar_item(admins_user_actions_path, '操作记录', icon: 'pencil-square', controller: 'admins-user_actions', has_permission: current_user.admin?) %>
  • <%= sidebar_item(admins_system_notifications_path, '系统公告配置', icon: 'bell', controller: 'admins-system_notifications', has_permission: current_user.admin? || current_user.business?) %>
  • <% end %> From 29ee61ab1be964a2fb0bb838b6ded5116aa6a37d Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 27 Sep 2024 09:55:53 +0800 Subject: [PATCH 21/75] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E6=9F=A5=E8=AF=A2=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user_actions/_user_action_list.html.erb | 2 +- app/views/admins/user_actions/index.html.erb | 19 +------------------ ...926031029_add_user_info_to_user_actions.rb | 14 +++++++------- 3 files changed, 9 insertions(+), 26 deletions(-) diff --git a/app/views/admins/user_actions/_user_action_list.html.erb b/app/views/admins/user_actions/_user_action_list.html.erb index 8577b2f29..0682e9036 100644 --- a/app/views/admins/user_actions/_user_action_list.html.erb +++ b/app/views/admins/user_actions/_user_action_list.html.erb @@ -14,7 +14,7 @@ <% if user_actions.present? %> <% user_actions.each_with_index do |action, index| %> - + <%= list_index_no((params[:page] || 1).to_i, index) %> <%= action.action_name %> diff --git a/app/views/admins/user_actions/index.html.erb b/app/views/admins/user_actions/index.html.erb index 8821a8be0..bf052b146 100644 --- a/app/views/admins/user_actions/index.html.erb +++ b/app/views/admins/user_actions/index.html.erb @@ -13,24 +13,7 @@ <% end %> - - - - - - <%# @user_nps_mid = @score_total_count % 2 == 0 ? @score_total_count / 2 : (@score_total_count + 1) / 2 %> - - - - - - - - - - - - +
    <%= render partial: 'admins/user_actions/user_action_list', locals: { user_actions: @user_actions } %>
    diff --git a/db/migrate/202410926031029_add_user_info_to_user_actions.rb b/db/migrate/202410926031029_add_user_info_to_user_actions.rb index e361d2b1d..967e8a68d 100644 --- a/db/migrate/202410926031029_add_user_info_to_user_actions.rb +++ b/db/migrate/202410926031029_add_user_info_to_user_actions.rb @@ -7,14 +7,14 @@ class AddUserInfoToUserActions < ActiveRecord::Migration[5.2] UserAction.find_in_batches(batch_size: 1000) do |sw| Parallel.each(sw, in_threads: 5) do |user_action| - next if user_action.user_id.blank? - user = User.find_by(id: user_action.user_id) - next if user.blank? - user_action.login = user.login - user_action.email = user.mail - user_action.phone = user.phone - user_action.save + if user_action.user.present? + user_action.login = user_action.user&.login + user_action.email = user_action.user&.mail + user_action.phone = user_action.user&.phone + user_action.save + end end end end + end From cf36e89f5605b0344c2a306b5923bac96ced1c78 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 27 Sep 2024 10:02:40 +0800 Subject: [PATCH 22/75] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E6=9F=A5=E8=AF=A2=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user_action.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/models/user_action.rb b/app/models/user_action.rb index 7405c0c44..cf797cfce 100644 --- a/app/models/user_action.rb +++ b/app/models/user_action.rb @@ -48,10 +48,11 @@ class UserAction < ApplicationRecord end def user - action_user = User.find_by(id: self.user_id) - if action_user.blank? - action_user = self.action_data - end + action_user = if action_type == "DestroyUser" && data_bank.present? + build_mode("User") + else + User.find_by(id: self.user_id) + end action_user end def build_mode(model_name) From f4525d6744a0e4d1a73177f1b557a9454c27ab0a Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 27 Sep 2024 10:13:35 +0800 Subject: [PATCH 23/75] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E6=9F=A5=E8=AF=A2=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user_action.rb | 8 ++++++++ app/views/admins/user_actions/_user_action_list.html.erb | 2 ++ 2 files changed, 10 insertions(+) diff --git a/app/models/user_action.rb b/app/models/user_action.rb index cf797cfce..07369dba9 100644 --- a/app/models/user_action.rb +++ b/app/models/user_action.rb @@ -47,6 +47,14 @@ class UserAction < ApplicationRecord end end + def opt_user_name + if user&.id == user_id + "--" + else + User.find_by(id: self.user_id)&.login + end + end + def user action_user = if action_type == "DestroyUser" && data_bank.present? build_mode("User") diff --git a/app/views/admins/user_actions/_user_action_list.html.erb b/app/views/admins/user_actions/_user_action_list.html.erb index 0682e9036..d19cdbc64 100644 --- a/app/views/admins/user_actions/_user_action_list.html.erb +++ b/app/views/admins/user_actions/_user_action_list.html.erb @@ -3,6 +3,7 @@ 序号 操作类型 + 操作人 账号 邮箱 手机号 @@ -17,6 +18,7 @@ <%= list_index_no((params[:page] || 1).to_i, index) %> <%= action.action_name %> + <%= action.opt_user_name %> <%= link_to "/#{action.user&.login}", target: '_blank' do %> <%= overflow_hidden_span action.user&.login, width: 100 %> From 17d47170ba8bdc8775209238ebcca4b88762d017 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 27 Sep 2024 10:16:07 +0800 Subject: [PATCH 24/75] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E6=9F=A5=E8=AF=A2=EF=BC=8C=E6=96=87=E6=A1=88?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user_action.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user_action.rb b/app/models/user_action.rb index 07369dba9..6f1a1d2fe 100644 --- a/app/models/user_action.rb +++ b/app/models/user_action.rb @@ -31,7 +31,7 @@ class UserAction < ApplicationRecord def action_name case action_type - when "DestroyUser" then "删除用户" + when "DestroyUser" then "注销用户" when "DestroyProject" then "删除项目" when "Login" then "登录" when "Logout" then "退出登录" From 11eb5d3f98a28b3def8d67baf01408be8293195d Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 27 Sep 2024 10:16:58 +0800 Subject: [PATCH 25/75] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E6=9F=A5=E8=AF=A2=EF=BC=8C=E6=96=87=E6=A1=88?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user_action.rb | 2 +- app/views/admins/user_actions/index.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/user_action.rb b/app/models/user_action.rb index 6f1a1d2fe..0c9a43347 100644 --- a/app/models/user_action.rb +++ b/app/models/user_action.rb @@ -31,7 +31,7 @@ class UserAction < ApplicationRecord def action_name case action_type - when "DestroyUser" then "注销用户" + when "DestroyUser" then "用户注销" when "DestroyProject" then "删除项目" when "Login" then "登录" when "Logout" then "退出登录" diff --git a/app/views/admins/user_actions/index.html.erb b/app/views/admins/user_actions/index.html.erb index bf052b146..e83e1e868 100644 --- a/app/views/admins/user_actions/index.html.erb +++ b/app/views/admins/user_actions/index.html.erb @@ -5,7 +5,7 @@
    <%= form_tag(admins_user_actions_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %> 操作类型: - <% action_type_options = [['自定义',''],['删除用户','DestroyUser'], ['删除项目', 'DestroyProject']] %> + <% action_type_options = [['自定义',''],['用户注销','DestroyUser'], ['删除项目', 'DestroyProject']] %> <%= select_tag(:action_type_select, options_for_select(action_type_options), class: 'form-control') %> <%= text_field_tag(:action_type, params[:action_type], class: 'form-control col-sm-2 ml-3',style: 'display:none;', placeholder: '自定义操作类型检索') %> <%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: '用户名/邮箱/手机号检索') %> From 25321648f62b6d16105cc7c3418a040dfc4c6b48 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 27 Sep 2024 10:22:30 +0800 Subject: [PATCH 26/75] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user_action.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user_action.rb b/app/models/user_action.rb index 0c9a43347..c3b2270c0 100644 --- a/app/models/user_action.rb +++ b/app/models/user_action.rb @@ -25,7 +25,7 @@ class UserAction < ApplicationRecord - before_create :add_user_info + before_save :add_user_info serialize :data_bank, JSON From 3fae388d92e88a037466d8d41621c5fe84fb7b28 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 27 Sep 2024 10:24:40 +0800 Subject: [PATCH 27/75] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user_action.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user_action.rb b/app/models/user_action.rb index c3b2270c0..6052e975c 100644 --- a/app/models/user_action.rb +++ b/app/models/user_action.rb @@ -25,7 +25,7 @@ class UserAction < ApplicationRecord - before_save :add_user_info + after_save :add_user_info serialize :data_bank, JSON From 19cf675f2e2a12781800efce7e45a183ab418be8 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 27 Sep 2024 10:42:03 +0800 Subject: [PATCH 28/75] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user_action.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/user_action.rb b/app/models/user_action.rb index 6052e975c..51b492053 100644 --- a/app/models/user_action.rb +++ b/app/models/user_action.rb @@ -66,9 +66,12 @@ class UserAction < ApplicationRecord def build_mode(model_name) model = model_name.constantize.new model_name.constantize.column_names.each do |col| - model[col] = self.data_bank[col] + data = self.data_bank.class == String ? JSON.parse(self.data_bank) : self.data_bank + model[col] = data[col] end model + rescue =>err + return nil end private From 80828d85d7fe039561da4238c2e069e31d7c1a64 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 27 Sep 2024 10:47:16 +0800 Subject: [PATCH 29/75] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user_action.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/models/user_action.rb b/app/models/user_action.rb index 51b492053..846c4e22c 100644 --- a/app/models/user_action.rb +++ b/app/models/user_action.rb @@ -76,10 +76,12 @@ class UserAction < ApplicationRecord private def add_user_info - if user.present? - self.login = user.login - self.email = user.mail - self.phone = user.phone + if self.login.blank? + if user.present? + self.login = user.login + self.email = user.mail + self.phone = user.phone + end end end end From 4329f9dbf0f3303c865b94b0cc480bf0fedf2805 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 27 Sep 2024 11:11:53 +0800 Subject: [PATCH 30/75] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=98=BE=E7=A4=BA=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admins/user_actions_controller.rb | 2 +- app/models/user_action.rb | 25 +++++++++++++------ .../user_actions/_user_action_list.html.erb | 21 ++++------------ 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/app/controllers/admins/user_actions_controller.rb b/app/controllers/admins/user_actions_controller.rb index d96cdc97e..ff52d5a1a 100644 --- a/app/controllers/admins/user_actions_controller.rb +++ b/app/controllers/admins/user_actions_controller.rb @@ -6,7 +6,7 @@ class Admins::UserActionsController < Admins::BaseController @user_actions = @user_actions.where(action_type: params[:action_type]) if params[:action_type].present? keyword = params[:keyword].to_s.strip.presence if keyword - sql = 'login LIKE :keyword OR phone LIKE :keyword OR mail LIKE :keyword' + sql = 'login LIKE :keyword OR phone LIKE :keyword OR email LIKE :keyword' @user_actions = @user_actions.where(sql, keyword: "%#{keyword}%") end @user_actions = paginate @user_actions diff --git a/app/models/user_action.rb b/app/models/user_action.rb index 846c4e22c..0df146bd9 100644 --- a/app/models/user_action.rb +++ b/app/models/user_action.rb @@ -39,14 +39,6 @@ class UserAction < ApplicationRecord end end - def action_data - case action_type - when "DestroyUser" then build_mode("User") - when "DestroyProject" then build_mode("Project") - else nil - end - end - def opt_user_name if user&.id == user_id "--" @@ -55,6 +47,14 @@ class UserAction < ApplicationRecord end end + def action_info + case action_type + when "DestroyUser" then "账号:#{user&.login}
    邮箱:#{user&.mail}
    手机号:#{user&.phone}
    昵称:#{user&.nickname}
    " + when "DestroyProject" then "项目名称:#{project&.name}
    项目标识:#{project&.identifier}
    " + else "--" + end + end + def user action_user = if action_type == "DestroyUser" && data_bank.present? build_mode("User") @@ -63,6 +63,15 @@ class UserAction < ApplicationRecord end action_user end + + def project + action_project = if action_type == "DestroyProject" && data_bank.present? + build_mode("Project") + else + Project.find_by(id: self.action_id) + end + action_project + end def build_mode(model_name) model = model_name.constantize.new model_name.constantize.column_names.each do |col| diff --git a/app/views/admins/user_actions/_user_action_list.html.erb b/app/views/admins/user_actions/_user_action_list.html.erb index d19cdbc64..0af34be7d 100644 --- a/app/views/admins/user_actions/_user_action_list.html.erb +++ b/app/views/admins/user_actions/_user_action_list.html.erb @@ -3,11 +3,8 @@ 序号 操作类型 - 操作人 - 账号 - 邮箱 - 手机号 - 姓名 + 操作人账号 + 关联基本信息 操作时间 原因/备注 @@ -18,20 +15,12 @@ <%= list_index_no((params[:page] || 1).to_i, index) %> <%= action.action_name %> - <%= action.opt_user_name %> <%= link_to "/#{action.user&.login}", target: '_blank' do %> <%= overflow_hidden_span action.user&.login, width: 100 %> - <% end %> - - - <%= overflow_hidden_span action.user&.mail, width: 150 %> - - <%= action.user&.phone %> - - <%= link_to "/#{action.user&.login}", target: '_blank' do %> - <%= overflow_hidden_span action.user&.real_name, width: 100 %> - <% end %> + <% end %> + + <%= raw action.action_info %> <%= display_text(action.created_at&.strftime('%Y-%m-%d %H:%M')) %> <%= action.memo %> From cb693dca8bc71dfc92813d3e9bef87c1cdbaf0f8 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 27 Sep 2024 11:15:45 +0800 Subject: [PATCH 31/75] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=98=BE=E7=A4=BA=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/users_controller.rb | 2 +- app/views/admins/user_actions/index.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index e8b064e9a..2c56178ea 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -131,7 +131,7 @@ class Api::V1::UsersController < Api::V1::BaseController org_count = Organization.where(id: org_ids).count project_count = Project.where(user_id: @observe_user.id).count return tip_exception(-1, "当前账号名下存在未删除或退出的组织/仓库,请先删除或退出后再尝试注销操作.") if org_count > 0 || project_count > 0 - UserAction.create(action_id: @observe_user.id, action_type: "DestroyUser", user_id: @observe_user.id, :ip => request.remote_ip, data_bank: @observe_user.attributes.to_json) + UserAction.create(action_id: @observe_user.id, action_type: "DestroyUser", user_id: @observe_user.id, :ip => request.remote_ip, data_bank: @observe_user.attributes.to_json, memo: params[:memo]) @result_object = Api::V1::Users::DeleteUserService.call(@observe_user) if @result_object return render_ok diff --git a/app/views/admins/user_actions/index.html.erb b/app/views/admins/user_actions/index.html.erb index e83e1e868..7b01591ee 100644 --- a/app/views/admins/user_actions/index.html.erb +++ b/app/views/admins/user_actions/index.html.erb @@ -8,7 +8,7 @@ <% action_type_options = [['自定义',''],['用户注销','DestroyUser'], ['删除项目', 'DestroyProject']] %> <%= select_tag(:action_type_select, options_for_select(action_type_options), class: 'form-control') %> <%= text_field_tag(:action_type, params[:action_type], class: 'form-control col-sm-2 ml-3',style: 'display:none;', placeholder: '自定义操作类型检索') %> - <%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: '用户名/邮箱/手机号检索') %> + <%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: '操作人用户名/邮箱/手机号检索') %> <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> <% end %> From 6574aff205dbc25ef00845a0e4a0527bd95499da Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 27 Sep 2024 11:17:59 +0800 Subject: [PATCH 32/75] =?UTF-8?q?fixed=20=E6=A3=80=E6=B5=8B=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=B8=8D=E5=AD=98=E5=9C=A8=E6=97=B6=E6=B8=85=E9=99=A4?= =?UTF-8?q?cookie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 27895a758..761a88fa8 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -714,6 +714,7 @@ class UsersController < ApplicationController private def load_user @user = User.find_by_login(params[:id]) || User.find_by(id: params[:id]) + clear_user_cookie unless @user.present? end def user_params From 6924366e022b40b1929e715338543bfb6b62969c Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 27 Sep 2024 11:28:59 +0800 Subject: [PATCH 33/75] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=98=BE=E7=A4=BA=E8=B0=83=E6=95=B4,?= =?UTF-8?q?=E4=B8=8D=E5=AD=98=E5=9C=A8=E7=94=A8=E6=88=B7=E4=BB=85=E6=98=BE?= =?UTF-8?q?=E7=A4=BAid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user_action.rb | 7 ++++--- app/views/admins/user_actions/_user_action_list.html.erb | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/models/user_action.rb b/app/models/user_action.rb index 0df146bd9..8f8df75bf 100644 --- a/app/models/user_action.rb +++ b/app/models/user_action.rb @@ -40,10 +40,11 @@ class UserAction < ApplicationRecord end def opt_user_name - if user&.id == user_id - "--" + user = User.find_by(id: self.user_id) + if user.present? + user&.login else - User.find_by(id: self.user_id)&.login + "不存用户:#{action_id}" end end diff --git a/app/views/admins/user_actions/_user_action_list.html.erb b/app/views/admins/user_actions/_user_action_list.html.erb index 0af34be7d..2df720b60 100644 --- a/app/views/admins/user_actions/_user_action_list.html.erb +++ b/app/views/admins/user_actions/_user_action_list.html.erb @@ -17,7 +17,7 @@ <%= action.action_name %> <%= link_to "/#{action.user&.login}", target: '_blank' do %> - <%= overflow_hidden_span action.user&.login, width: 100 %> + <%= overflow_hidden_span action.opt_user_name, width: 100 %> <% end %> <%= raw action.action_info %> From c73e138ee778c71a3a900bd84afcce3b4e0b1deb Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 27 Sep 2024 11:33:42 +0800 Subject: [PATCH 34/75] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=98=BE=E7=A4=BA=E8=B0=83=E6=95=B4,?= =?UTF-8?q?=E4=B8=8D=E5=AD=98=E5=9C=A8=E7=94=A8=E6=88=B7=E4=BB=85=E6=98=BE?= =?UTF-8?q?=E7=A4=BAid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user_action.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/user_action.rb b/app/models/user_action.rb index 8f8df75bf..7895446e3 100644 --- a/app/models/user_action.rb +++ b/app/models/user_action.rb @@ -44,7 +44,8 @@ class UserAction < ApplicationRecord if user.present? user&.login else - "不存用户:#{action_id}" + del_user = UserAction.find_by(action_type: "DestroyUser", action_id: self.user_id) + del_user.present? ? "已注销:#{del_user.user.login}" : "不存在用户:#{user_id}" end end From 25978fb97e2fcfd64815df1b4e9dac9ccaa0985f Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 27 Sep 2024 11:35:28 +0800 Subject: [PATCH 35/75] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=98=BE=E7=A4=BA=E8=B0=83=E6=95=B4,?= =?UTF-8?q?=E4=B8=8D=E5=AD=98=E5=9C=A8=E7=94=A8=E6=88=B7=E4=BB=85=E6=98=BE?= =?UTF-8?q?=E7=A4=BAid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user_action.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user_action.rb b/app/models/user_action.rb index 7895446e3..289fa188e 100644 --- a/app/models/user_action.rb +++ b/app/models/user_action.rb @@ -45,7 +45,7 @@ class UserAction < ApplicationRecord user&.login else del_user = UserAction.find_by(action_type: "DestroyUser", action_id: self.user_id) - del_user.present? ? "已注销:#{del_user.user.login}" : "不存在用户:#{user_id}" + del_user.present? ? del_user.user.login : "不存在用户:#{user_id}" end end From 3f9cac37c8f4f2be6ecefeb1afa000aedce59d82 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 27 Sep 2024 11:37:09 +0800 Subject: [PATCH 36/75] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=98=BE=E7=A4=BA=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/admins/user_actions/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admins/user_actions/index.html.erb b/app/views/admins/user_actions/index.html.erb index 7b01591ee..8a5900151 100644 --- a/app/views/admins/user_actions/index.html.erb +++ b/app/views/admins/user_actions/index.html.erb @@ -5,7 +5,7 @@
    <%= form_tag(admins_user_actions_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %> 操作类型: - <% action_type_options = [['自定义',''],['用户注销','DestroyUser'], ['删除项目', 'DestroyProject']] %> + <% action_type_options = [['用户注销','DestroyUser'], ['删除项目', 'DestroyProject'],['自定义','']] %> <%= select_tag(:action_type_select, options_for_select(action_type_options), class: 'form-control') %> <%= text_field_tag(:action_type, params[:action_type], class: 'form-control col-sm-2 ml-3',style: 'display:none;', placeholder: '自定义操作类型检索') %> <%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: '操作人用户名/邮箱/手机号检索') %> From f213ce23af3b30d86ebaa5ab986685b45c04f3b1 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 27 Sep 2024 11:42:16 +0800 Subject: [PATCH 37/75] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=98=BE=E7=A4=BA=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/admins/user_actions/index.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/admins/user_actions/index.html.erb b/app/views/admins/user_actions/index.html.erb index 8a5900151..ae62414c8 100644 --- a/app/views/admins/user_actions/index.html.erb +++ b/app/views/admins/user_actions/index.html.erb @@ -5,9 +5,9 @@
    <%= form_tag(admins_user_actions_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %> 操作类型: - <% action_type_options = [['用户注销','DestroyUser'], ['删除项目', 'DestroyProject'],['自定义','']] %> + <% action_type_options = [['自定义',''],['用户注销','DestroyUser'], ['删除项目', 'DestroyProject']] %> <%= select_tag(:action_type_select, options_for_select(action_type_options), class: 'form-control') %> - <%= text_field_tag(:action_type, params[:action_type], class: 'form-control col-sm-2 ml-3',style: 'display:none;', placeholder: '自定义操作类型检索') %> + <%= text_field_tag(:action_type, params[:action_type], class: 'form-control col-sm-2 ml-3',style: 'display:;', placeholder: '自定义操作类型检索') %> <%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: '操作人用户名/邮箱/手机号检索') %> <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> <% end %> From 75c61bfff50f2789fa049af14c77fda0d9296abf Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 27 Sep 2024 14:19:52 +0800 Subject: [PATCH 38/75] =?UTF-8?q?=E5=90=88=E5=B9=B6=E5=8C=BA=E5=9D=97?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/queries/application_query.rb | 20 ++++++++++++++++++++ app/queries/blockchain/balance_query.rb | 10 ++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/app/queries/application_query.rb b/app/queries/application_query.rb index e2d7c446f..4d43bfeb6 100644 --- a/app/queries/application_query.rb +++ b/app/queries/application_query.rb @@ -24,6 +24,26 @@ class ApplicationQuery end end + # find one repo that a user has tokens + def find_one_balance_with_token(user_id, project_id) + # return 3 statuses: UnknownErr/ResUserNotExisted/Success + params = { + "request-type": "query user balance of single repo", + "username": user_id.to_s, + "token_name": project_id.to_s + }.to_json + Rails.logger.info "query user balance of single repo params======= #{params}" + resp_body = Blockchain::InvokeBlockchainApi.call(params) + Rails.logger.info "resp_body======= #{resp_body}" + if resp_body['status'] == 0 + return resp_body + elsif resp_body['status'] == 100 + return 0 # 找不到用户返回0 + else + raise "区块链接口请求失败." + end + end + # find one repo that a user has tokens def find_one_balance(user_id, project_id) diff --git a/app/queries/blockchain/balance_query.rb b/app/queries/blockchain/balance_query.rb index 045d2fe8a..d50b38ee6 100644 --- a/app/queries/blockchain/balance_query.rb +++ b/app/queries/blockchain/balance_query.rb @@ -11,9 +11,15 @@ class Blockchain::BalanceQuery < ApplicationQuery if is_current_admin_user result_list = [] if params[:project_id].present? or params[:keyword].present? - project_ids = params[:project_id].present? ? [params[:project_id]] : Project.where(user_id: params["user_id"]).like(params[:keyword]).ids + token_list, total_count = find_repo_with_token(params["user_id"], 1, 10000) + p_ids = [] + token_list.each do |t| + p_ids.push(t['token_name'].to_i) + end + project_ids = params[:project_id].present? ? [params[:project_id]] : Project.where(id: p_ids).like(params[:keyword]).ids project_ids.each do |project_id| - project_balance = find_one_balance(params["user_id"], project_id) + project_balance = find_one_balance_with_token(params["user_id"], project_id) + next if project_balance == 0 project = Project.find_by(id: project_balance['token_name'].to_i) if project.present? owner = User.find_by(id: project.user_id) From d5a2580ae914791bf1d46a42cd3551e67e27055e Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 27 Sep 2024 14:27:36 +0800 Subject: [PATCH 39/75] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 202bae458..0b861655e 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -253,6 +253,7 @@ class ProjectsController < ApplicationController def destroy if current_user.admin? || @project.manager?(current_user) ActiveRecord::Base.transaction do + UserAction.create(action_id: @project.id, action_type: "DestroyProject", user_id: current_user.id, :ip => request.remote_ip, data_bank: @project.attributes.to_json) close_fork_pull_requests_by(@project) Gitea::Repository::DeleteService.new(@project.owner, @project.identifier,current_user.gitea_token).call @project.destroy! From 83dc605c260e1472f51811295741d525b4627ab1 Mon Sep 17 00:00:00 2001 From: yystopf Date: Fri, 27 Sep 2024 15:04:10 +0800 Subject: [PATCH 40/75] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=A6=82=E8=A7=88=E6=97=A0=E6=B3=95=E6=AD=A3=E5=B8=B8?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=99=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 0b861655e..4724224e8 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -366,7 +366,7 @@ class ProjectsController < ApplicationController if @project_detail.save! attachment_ids = Array(params[:attachment_ids]) logger.info "=============> #{Array(params[:attachment_ids])}" - @attachments = Attachment.where(id: attachment_ids) + @attachments = Attachment.where(id: attachment_ids).or(Attachment.where(uuid: attachment_ids)) @attachments.update_all( container_id: @project_detail.id, container_type: @project_detail.model_name.name, From b9b3d875ed97be679dcd3614ab0ce118dee4b2da Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 30 Sep 2024 14:48:04 +0800 Subject: [PATCH 41/75] =?UTF-8?q?fixed=20=E6=A3=80=E6=B5=8B=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=8B=A5=E6=9C=89=E7=BB=84=E7=BB=87=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/users_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index 2c56178ea..2ed5072a2 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -119,7 +119,7 @@ class Api::V1::UsersController < Api::V1::BaseController def check_user_can_delete org_ids = TeamUser.where(user_id: @observe_user.id).pluck(:organization_id) | OrganizationUser.where(user_id: @observe_user.id).pluck(:organization_id) - org_count = Organization.where(id: org_ids).count + org_count = TeamUser.where(organization_id: org_ids).where(user_id: @observe_user.id).joins(:team).where(teams: {authorize: %w(owner)}).count project_count = Project.where(user_id: @observe_user.id).count render_ok({ can_delete: org_count == 0 && project_count == 0, org_count: org_count, project_count: project_count }) end @@ -128,7 +128,7 @@ class Api::V1::UsersController < Api::V1::BaseController def destroy return tip_exception(-1, "密码不正确.") unless @observe_user.check_password?(params[:password]) org_ids = TeamUser.where(user_id: @observe_user.id).pluck(:organization_id) | OrganizationUser.where(user_id: @observe_user.id).pluck(:organization_id) - org_count = Organization.where(id: org_ids).count + org_count = TeamUser.where(organization_id: org_ids).where(user_id: @observe_user.id).joins(:team).where(teams: {authorize: %w(owner)}).count project_count = Project.where(user_id: @observe_user.id).count return tip_exception(-1, "当前账号名下存在未删除或退出的组织/仓库,请先删除或退出后再尝试注销操作.") if org_count > 0 || project_count > 0 UserAction.create(action_id: @observe_user.id, action_type: "DestroyUser", user_id: @observe_user.id, :ip => request.remote_ip, data_bank: @observe_user.attributes.to_json, memo: params[:memo]) From 65a7af3d6e4028a52b6b6ceca3277c0bb69f15c2 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Tue, 8 Oct 2024 09:26:24 +0800 Subject: [PATCH 42/75] =?UTF-8?q?fixed=20=E7=BB=84=E7=BB=87id=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E7=89=B9=E6=AE=8A=E7=AC=A6=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/routes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index 501a024b4..aab65db4c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -142,7 +142,7 @@ Rails.application.routes.draw do post '/blockchain/issue/get_token_num', to: 'users#blockchain_get_issue_token_num' get '/projects/blockchain/get_unclosed_issue_list', to: 'users#blockchain_get_unclosed_issue_list' - resources :owners, only: [:index, :show] + resources :owners, only: [:index, :show], constraints: { id: /[^\/]+/ } scope module: :organizations do resources :organizations, except: [:edit, :new] do From ea76beb1bf3d306e58da58a2bdbeecbb68b85613 Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 8 Oct 2024 10:22:13 +0800 Subject: [PATCH 43/75] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E5=A4=84?= =?UTF-8?q?=E7=90=86owners=20.json=E5=90=8E=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/owners_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/owners_controller.rb b/app/controllers/owners_controller.rb index eadbdbf95..7ca5f0d39 100644 --- a/app/controllers/owners_controller.rb +++ b/app/controllers/owners_controller.rb @@ -11,7 +11,8 @@ class OwnersController < ApplicationController end def show - @owner = Owner.find_by(login: params[:id]) || Owner.find_by(id: params[:id]) + login = params[:id].to_s[0..-6] + @owner = Owner.find_by(login: login) || Owner.find_by(id: login) clear_user_cookie unless @owner.present? return render_not_found unless @owner.present? # 组织 From 05e3036a2f40ec9c67f5019d87d717bb552ba5b7 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Tue, 8 Oct 2024 11:17:14 +0800 Subject: [PATCH 44/75] =?UTF-8?q?fixed=20=20=E5=88=A0=E9=99=A4=E7=BB=84?= =?UTF-8?q?=E7=BB=87id=E6=94=AF=E6=8C=81=E7=89=B9=E6=AE=8A=E7=AC=A6?= =?UTF-8?q?=E5=8F=B7=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/routes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index aab65db4c..501a024b4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -142,7 +142,7 @@ Rails.application.routes.draw do post '/blockchain/issue/get_token_num', to: 'users#blockchain_get_issue_token_num' get '/projects/blockchain/get_unclosed_issue_list', to: 'users#blockchain_get_unclosed_issue_list' - resources :owners, only: [:index, :show], constraints: { id: /[^\/]+/ } + resources :owners, only: [:index, :show] scope module: :organizations do resources :organizations, except: [:edit, :new] do From bd19bb1251886521379d026e69ed40077cea0143 Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 8 Oct 2024 11:22:42 +0800 Subject: [PATCH 45/75] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9Aowners?= =?UTF-8?q?=E8=8E=B7=E5=8F=96id=E5=9B=9E=E9=80=80=E5=88=B0=E4=B9=8B?= =?UTF-8?q?=E5=89=8D=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/owners_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/owners_controller.rb b/app/controllers/owners_controller.rb index 7ca5f0d39..ad3a70423 100644 --- a/app/controllers/owners_controller.rb +++ b/app/controllers/owners_controller.rb @@ -11,7 +11,8 @@ class OwnersController < ApplicationController end def show - login = params[:id].to_s[0..-6] + # login = params[:id].to_s[0..-6] + login = params[:id].to_s @owner = Owner.find_by(login: login) || Owner.find_by(id: login) clear_user_cookie unless @owner.present? return render_not_found unless @owner.present? From 66a7c4eb0013e157f8e97fb943480d84517458f1 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Tue, 8 Oct 2024 15:01:38 +0800 Subject: [PATCH 46/75] =?UTF-8?q?fixed=20=20=E5=88=A0=E9=99=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=97=B6=E5=88=A0=E9=99=A4=E8=AE=A8=E8=AE=BA=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/v1/users/delete_user_service.rb | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/services/api/v1/users/delete_user_service.rb b/app/services/api/v1/users/delete_user_service.rb index 67714de06..12775eac3 100644 --- a/app/services/api/v1/users/delete_user_service.rb +++ b/app/services/api/v1/users/delete_user_service.rb @@ -13,14 +13,16 @@ class Api::V1::Users::DeleteUserService < ApplicationService # org.team_users.joins(:team).where(user_id: @user.id, teams: {authorize: %w(owner)}) owner_count = org.team_users.joins(:team).where(teams: {authorize: %w(owner)}).count # 多个owner时,仅将用户从组织移除, 一个时直接删除 - if owner_count > 1 - org.team_users.joins(:team).where(user_id: @user.id, teams: {authorize: %w(owner)}).destroy_all - org.organization_users.where(user_id: @user.id, organization_id: org.id).destroy_all - else - org.destroy + org.team_users.where(user_id: @user.id).destroy_all + org.organization_users.where(user_id: @user.id, organization_id: org.id).destroy_all + if owner_count == 1 + if org.team_users.joins(:team).where(user_id: @user.id, teams: { authorize: %w(owner) }).count > 0 + org.destroy! + end end end @user.destroy! + del_user_data_by_sql(@user.id) Gitea::User::DeleteService.call(@user.login, true) end return true @@ -28,4 +30,9 @@ class Api::V1::Users::DeleteUserService < ApplicationService raise Error, "服务器错误,请联系系统管理员!" end end + + def del_user_data_by_sql(user_id) + sql1 = "delete from memos where author_id=#{user_id}" + ActiveRecord::Base.connection.execute(sql1) + end end \ No newline at end of file From 4e855a2a7b927708cf8afd387e72d28cf7aa8bee Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 9 Oct 2024 15:00:23 +0800 Subject: [PATCH 47/75] =?UTF-8?q?fixed=20=20=E5=88=A0=E9=99=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=97=B6issue=EF=BC=8Cpr=E8=B7=9F=E9=9A=8F=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/pull_request.rb | 2 +- app/models/user.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/pull_request.rb b/app/models/pull_request.rb index 26b4ce2c6..8d276625e 100644 --- a/app/models/pull_request.rb +++ b/app/models/pull_request.rb @@ -34,7 +34,7 @@ class PullRequest < ApplicationRecord belongs_to :issue belongs_to :user - belongs_to :project, counter_cache: true, touch: true + belongs_to :project, counter_cache: true, touch: true, optional: true belongs_to :fork_project, class_name: 'Project', foreign_key: :fork_project_id, optional: true has_many :pull_request_assigns, foreign_key: :pull_request_id has_many :pull_request_tags, foreign_key: :pull_request_id diff --git a/app/models/user.rb b/app/models/user.rb index 988f6d8c2..99fd2372d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -168,8 +168,8 @@ class User < Owner has_many :pinned_projects, dependent: :destroy has_many :is_pinned_projects, through: :pinned_projects, source: :project accepts_nested_attributes_for :is_pinned_projects - has_many :issues, dependent: :destroy, foreign_key: :author_id - has_many :pull_requests, dependent: :destroy + has_many :issues, foreign_key: :author_id + has_many :pull_requests has_many :public_keys, class_name: "Gitea::PublicKey",primary_key: :gitea_uid, foreign_key: :owner_id, dependent: :destroy has_one :user_template_message_setting, dependent: :destroy From 4002245601f2f9f6e67d89f994245af642780c65 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 9 Oct 2024 15:31:17 +0800 Subject: [PATCH 48/75] =?UTF-8?q?fixed=20=20=E5=88=A0=E9=99=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=97=B6issue=EF=BC=8Cpr=E7=94=A8=E6=88=B7=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=B7=B2=E6=B3=A8=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 4 ++-- app/views/api/v1/issues/_detail.json.jbuilder | 12 ++---------- app/views/api/v1/users/_simple_user.json.jbuilder | 5 +++-- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d670e9a0d..a54d345fa 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -148,9 +148,9 @@ module ApplicationHelper if File.exist?(disk_filename(source&.class, source&.id)) ctime = File.ctime(disk_filename(source.class, source.id)).to_i if %w(User Organization).include?(source.class.to_s) - File.join("images", relative_path, ["#{source.class}", "#{source.id}"]) + "?t=#{ctime}" + File.join("images", relative_path, ["#{source.class}", "#{source&.id}"]) + "?t=#{ctime}" else - File.join("images/avatars", ["#{source.class}", "#{source.id}"]) + "?t=#{ctime}" + File.join("images/avatars", ["#{source.class}", "#{source&.id}"]) + "?t=#{ctime}" end elsif source.class.to_s == 'User' source.get_letter_avatar_url diff --git a/app/views/api/v1/issues/_detail.json.jbuilder b/app/views/api/v1/issues/_detail.json.jbuilder index 8b5ff5949..941245b8c 100644 --- a/app/views/api/v1/issues/_detail.json.jbuilder +++ b/app/views/api/v1/issues/_detail.json.jbuilder @@ -27,18 +27,10 @@ json.milestone do end end json.author do - if issue.user.present? - json.partial! "api/v1/users/simple_user", locals: {user: issue.user} - else - json.nil! - end + json.partial! "api/v1/users/simple_user", locals: {user: issue.user} end json.changer do - if issue.changer.present? - json.partial! "api/v1/users/simple_user", locals: {user: issue.changer} - else - json.nil! - end + json.partial! "api/v1/users/simple_user", locals: {user: issue.changer} end json.assigners issue.show_assigners.each do |assigner| json.partial! "api/v1/users/simple_user", locals: {user: assigner} diff --git a/app/views/api/v1/users/_simple_user.json.jbuilder b/app/views/api/v1/users/_simple_user.json.jbuilder index 5e8e970e7..f79729046 100644 --- a/app/views/api/v1/users/_simple_user.json.jbuilder +++ b/app/views/api/v1/users/_simple_user.json.jbuilder @@ -4,6 +4,7 @@ if user.present? json.name user.real_name json.login user.login json.image_url Rails.application.config_for(:configuration)['platform_url'] + "/" + url_to_avatar(user).to_s -else - json.nil! +else + json.name "已注销" + json.login "" end \ No newline at end of file From d5656f1d7abe293a0a6c2b3bc0b914a8d3958898 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 9 Oct 2024 15:34:19 +0800 Subject: [PATCH 49/75] =?UTF-8?q?fixed=20=20=E5=88=A0=E9=99=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=97=B6issue=EF=BC=8Cpr=E7=94=A8=E6=88=B7=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=B7=B2=E6=B3=A8=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/api/v1/issues/_simple_detail.json.jbuilder | 6 +----- app/views/api/v1/users/_simple_user.json.jbuilder | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/app/views/api/v1/issues/_simple_detail.json.jbuilder b/app/views/api/v1/issues/_simple_detail.json.jbuilder index 15259baa5..f3a4a12fd 100644 --- a/app/views/api/v1/issues/_simple_detail.json.jbuilder +++ b/app/views/api/v1/issues/_simple_detail.json.jbuilder @@ -33,11 +33,7 @@ json.time_scale issue.time_scale json.child_count issue.child_count json.author do - if issue.user.present? - json.partial! "api/v1/users/simple_user", locals: {user: issue.user} - else - json.nil! - end + json.partial! "api/v1/users/simple_user", locals: {user: issue.user} end json.assigners issue.show_assigners.each do |assigner| json.partial! "api/v1/users/simple_user", locals: {user: assigner} diff --git a/app/views/api/v1/users/_simple_user.json.jbuilder b/app/views/api/v1/users/_simple_user.json.jbuilder index f79729046..27fb3d13d 100644 --- a/app/views/api/v1/users/_simple_user.json.jbuilder +++ b/app/views/api/v1/users/_simple_user.json.jbuilder @@ -7,4 +7,5 @@ if user.present? else json.name "已注销" json.login "" + json.image_url Rails.application.config_for(:configuration)['platform_url'] + "/" + url_to_avatar(user).to_s end \ No newline at end of file From 2e0eab0d59fd8500849e75282fad517a4b8744ee Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 9 Oct 2024 15:36:18 +0800 Subject: [PATCH 50/75] =?UTF-8?q?fixed=20=20=E5=88=A0=E9=99=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=97=B6issue=EF=BC=8Cpr=E7=94=A8=E6=88=B7=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=B7=B2=E6=B3=A8=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/avatar_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/avatar_helper.rb b/app/helpers/avatar_helper.rb index b703e1b4e..607e4ce29 100644 --- a/app/helpers/avatar_helper.rb +++ b/app/helpers/avatar_helper.rb @@ -15,9 +15,9 @@ module AvatarHelper if File.exist?(disk_filename(source&.class, source&.id)) ctime = File.ctime(disk_filename(source.class, source.id)).to_i if %w(User Organization).include?(source.class.to_s) - File.join("images", relative_path, ["#{source.class}", "#{source.id}"]) + "?t=#{ctime}" + File.join("images", relative_path, ["#{source.class}", "#{source&.id}"]) + "?t=#{ctime}" else - File.join("images/avatars", ["#{source.class}", "#{source.id}"]) + "?t=#{ctime}" + File.join("images/avatars", ["#{source.class}", "#{source&.id}"]) + "?t=#{ctime}" end elsif source.class.to_s == 'User' source.get_letter_avatar_url From 34ee9d1cbf04633162d7ae085d2f74f2c34ca0c2 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 9 Oct 2024 15:38:12 +0800 Subject: [PATCH 51/75] =?UTF-8?q?fixed=20=20=E5=88=A0=E9=99=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=97=B6issue=EF=BC=8Cpr=E7=94=A8=E6=88=B7=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=B7=B2=E6=B3=A8=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 2 +- app/helpers/avatar_helper.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a54d345fa..682c647f0 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -146,7 +146,7 @@ module ApplicationHelper # 用户图像url,如果不存在的话,source为匿名用户,即默认使用匿名用户图像 def url_to_avatar(source) if File.exist?(disk_filename(source&.class, source&.id)) - ctime = File.ctime(disk_filename(source.class, source.id)).to_i + ctime = File.ctime(disk_filename(source.class, source&.id)).to_i if %w(User Organization).include?(source.class.to_s) File.join("images", relative_path, ["#{source.class}", "#{source&.id}"]) + "?t=#{ctime}" else diff --git a/app/helpers/avatar_helper.rb b/app/helpers/avatar_helper.rb index 607e4ce29..21cffd1be 100644 --- a/app/helpers/avatar_helper.rb +++ b/app/helpers/avatar_helper.rb @@ -13,7 +13,7 @@ module AvatarHelper def url_to_avatar(source) if File.exist?(disk_filename(source&.class, source&.id)) - ctime = File.ctime(disk_filename(source.class, source.id)).to_i + ctime = File.ctime(disk_filename(source.class, source&.id)).to_i if %w(User Organization).include?(source.class.to_s) File.join("images", relative_path, ["#{source.class}", "#{source&.id}"]) + "?t=#{ctime}" else From 6f8ccea616e6050d2bfb6205ada25316e2259a4a Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 9 Oct 2024 15:41:29 +0800 Subject: [PATCH 52/75] =?UTF-8?q?fixed=20=20=E5=88=A0=E9=99=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=97=B6issue=EF=BC=8Cpr=E7=94=A8=E6=88=B7=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=B7=B2=E6=B3=A8=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 10 +++++----- app/helpers/avatar_helper.rb | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 682c647f0..bab9ee9b2 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -146,13 +146,13 @@ module ApplicationHelper # 用户图像url,如果不存在的话,source为匿名用户,即默认使用匿名用户图像 def url_to_avatar(source) if File.exist?(disk_filename(source&.class, source&.id)) - ctime = File.ctime(disk_filename(source.class, source&.id)).to_i - if %w(User Organization).include?(source.class.to_s) - File.join("images", relative_path, ["#{source.class}", "#{source&.id}"]) + "?t=#{ctime}" + ctime = File.ctime(disk_filename(source&.class, source&.id)).to_i + if %w(User Organization).include?(source&.class.to_s) + File.join("images", relative_path, ["#{source&.class}", "#{source&.id}"]) + "?t=#{ctime}" else - File.join("images/avatars", ["#{source.class}", "#{source&.id}"]) + "?t=#{ctime}" + File.join("images/avatars", ["#{source&.class}", "#{source&.id}"]) + "?t=#{ctime}" end - elsif source.class.to_s == 'User' + elsif source&.class.to_s == 'User' source.get_letter_avatar_url end end diff --git a/app/helpers/avatar_helper.rb b/app/helpers/avatar_helper.rb index 21cffd1be..ad0ec0cde 100644 --- a/app/helpers/avatar_helper.rb +++ b/app/helpers/avatar_helper.rb @@ -13,13 +13,13 @@ module AvatarHelper def url_to_avatar(source) if File.exist?(disk_filename(source&.class, source&.id)) - ctime = File.ctime(disk_filename(source.class, source&.id)).to_i - if %w(User Organization).include?(source.class.to_s) - File.join("images", relative_path, ["#{source.class}", "#{source&.id}"]) + "?t=#{ctime}" + ctime = File.ctime(disk_filename(source&.class, source&.id)).to_i + if %w(User Organization).include?(source&.class.to_s) + File.join("images", relative_path, ["#{source&.class}", "#{source&.id}"]) + "?t=#{ctime}" else - File.join("images/avatars", ["#{source.class}", "#{source&.id}"]) + "?t=#{ctime}" + File.join("images/avatars", ["#{source&.class}", "#{source&.id}"]) + "?t=#{ctime}" end - elsif source.class.to_s == 'User' + elsif source&.class.to_s == 'User' source.get_letter_avatar_url end end From 71bdde79ef2e353c18cac7fe4906a16833fcc89f Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 9 Oct 2024 15:55:42 +0800 Subject: [PATCH 53/75] =?UTF-8?q?fixed=20=20=E5=88=A0=E9=99=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=97=B6issue=EF=BC=8Cpr=E7=94=A8=E6=88=B7=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=B7=B2=E6=B3=A8=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/api/v1/users/_simple_user.json.jbuilder | 2 +- app/views/pull_requests/index.json.jbuilder | 4 ++-- app/views/pull_requests/show.json.jbuilder | 4 ++-- app/views/users/_user_simple.json.jbuilder | 6 ++++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/views/api/v1/users/_simple_user.json.jbuilder b/app/views/api/v1/users/_simple_user.json.jbuilder index 27fb3d13d..a02503828 100644 --- a/app/views/api/v1/users/_simple_user.json.jbuilder +++ b/app/views/api/v1/users/_simple_user.json.jbuilder @@ -7,5 +7,5 @@ if user.present? else json.name "已注销" json.login "" - json.image_url Rails.application.config_for(:configuration)['platform_url'] + "/" + url_to_avatar(user).to_s + json.image_url Rails.application.config_for(:configuration)['platform_url'] + "/" + User::Avatar.get_letter_avatar_url("D") end \ No newline at end of file diff --git a/app/views/pull_requests/index.json.jbuilder b/app/views/pull_requests/index.json.jbuilder index 3a35772f0..b648d8bae 100644 --- a/app/views/pull_requests/index.json.jbuilder +++ b/app/views/pull_requests/index.json.jbuilder @@ -35,9 +35,9 @@ json.issues do json.pr_full_time pr.status == 1 ? pr.updated_at : issue.updated_on json.assign_user_name issue.get_assign_user.try(:show_real_name) json.assign_user_login issue.get_assign_user.try(:login) - json.author_name issue.user.try(:show_real_name) + json.author_name issue.user.blank?? "已注销": issue.user.show_real_name json.author_login issue.user.try(:login) - json.avatar_url url_to_avatar(issue.user) + json.avatar_url issue.user.blank?? User::Avatar.get_letter_avatar_url("D") : url_to_avatar(issue.user) json.priority issue.priority.try(:name) json.version issue.version.try(:name) json.journals_count issue.get_journals_size diff --git a/app/views/pull_requests/show.json.jbuilder b/app/views/pull_requests/show.json.jbuilder index 509577edc..c11be046d 100644 --- a/app/views/pull_requests/show.json.jbuilder +++ b/app/views/pull_requests/show.json.jbuilder @@ -44,9 +44,9 @@ json.issue do json.created_at format_time(@issue.created_on) json.assign_user_name @issue_assign_to.try(:show_real_name) json.assign_user_login @issue_assign_to.try(:login) - json.author_name @issue_user.try(:show_real_name) + json.author_name @issue_user.blank?? "已注销": @issue_user.show_real_name json.author_login @issue_user.try(:login) - json.author_picture url_to_avatar(@issue_user) + json.avatar_url @issue_user.blank?? User::Avatar.get_letter_avatar_url("D") : url_to_avatar(@issue_user) json.issue_status @issue.issue_status.try(:name) json.priority @issue.priority.try(:name) json.version @issue.version.try(:name) diff --git a/app/views/users/_user_simple.json.jbuilder b/app/views/users/_user_simple.json.jbuilder index 5da161509..c45706fe5 100644 --- a/app/views/users/_user_simple.json.jbuilder +++ b/app/views/users/_user_simple.json.jbuilder @@ -4,6 +4,8 @@ if user.present? json.name user.real_name json.login user.login json.image_url url_to_avatar(user) -else - json.nil! +else + json.name "已注销" + json.login "" + json.image_url Rails.application.config_for(:configuration)['platform_url'] + "/" + User::Avatar.get_letter_avatar_url("D") end \ No newline at end of file From 1459e2f62648ffa0c30fe2aac929866ee002ba38 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 9 Oct 2024 16:09:42 +0800 Subject: [PATCH 54/75] =?UTF-8?q?fixed=20=20=E5=88=A0=E9=99=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=97=B6issue=EF=BC=8Cpr=E7=94=A8=E6=88=B7=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=B7=B2=E6=B3=A8=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/api/v1/users/_simple_user.json.jbuilder | 3 ++- app/views/users/_user_simple.json.jbuilder | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/api/v1/users/_simple_user.json.jbuilder b/app/views/api/v1/users/_simple_user.json.jbuilder index a02503828..4d7518bb2 100644 --- a/app/views/api/v1/users/_simple_user.json.jbuilder +++ b/app/views/api/v1/users/_simple_user.json.jbuilder @@ -6,6 +6,7 @@ if user.present? json.image_url Rails.application.config_for(:configuration)['platform_url'] + "/" + url_to_avatar(user).to_s else json.name "已注销" - json.login "" + json.login user&.login + json.type "User" json.image_url Rails.application.config_for(:configuration)['platform_url'] + "/" + User::Avatar.get_letter_avatar_url("D") end \ No newline at end of file diff --git a/app/views/users/_user_simple.json.jbuilder b/app/views/users/_user_simple.json.jbuilder index c45706fe5..2fa5c2717 100644 --- a/app/views/users/_user_simple.json.jbuilder +++ b/app/views/users/_user_simple.json.jbuilder @@ -6,6 +6,7 @@ if user.present? json.image_url url_to_avatar(user) else json.name "已注销" - json.login "" + json.login user&.login + json.type "User" json.image_url Rails.application.config_for(:configuration)['platform_url'] + "/" + User::Avatar.get_letter_avatar_url("D") end \ No newline at end of file From 1233daa46643d2c156522fa1eb947c99d6f24283 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 9 Oct 2024 16:16:52 +0800 Subject: [PATCH 55/75] =?UTF-8?q?fixed=20=20=E5=88=A0=E9=99=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=97=B6issue=EF=BC=8Cpr=E7=94=A8=E6=88=B7=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=B7=B2=E6=B3=A8=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/pull_requests/show.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/pull_requests/show.json.jbuilder b/app/views/pull_requests/show.json.jbuilder index c11be046d..7420a7c37 100644 --- a/app/views/pull_requests/show.json.jbuilder +++ b/app/views/pull_requests/show.json.jbuilder @@ -46,7 +46,7 @@ json.issue do json.assign_user_login @issue_assign_to.try(:login) json.author_name @issue_user.blank?? "已注销": @issue_user.show_real_name json.author_login @issue_user.try(:login) - json.avatar_url @issue_user.blank?? User::Avatar.get_letter_avatar_url("D") : url_to_avatar(@issue_user) + json.author_picture @issue_user.blank?? User::Avatar.get_letter_avatar_url("D") : url_to_avatar(@issue_user) json.issue_status @issue.issue_status.try(:name) json.priority @issue.priority.try(:name) json.version @issue.version.try(:name) From 9c8e3f44bb35b5b1f94ed7e42fec5304d9675343 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 9 Oct 2024 16:51:07 +0800 Subject: [PATCH 56/75] =?UTF-8?q?fixed=20=20=E5=90=8E=E5=8F=B0=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E9=85=8D=E7=BD=AE=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/admins/edu_settings/_list.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admins/edu_settings/_list.html.erb b/app/views/admins/edu_settings/_list.html.erb index a37cc9bef..5dc0e1483 100644 --- a/app/views/admins/edu_settings/_list.html.erb +++ b/app/views/admins/edu_settings/_list.html.erb @@ -17,7 +17,7 @@ <%= edu_setting.name %> - <%= edu_setting.value %> + <%= edu_setting.value %> <%= overflow_hidden_span display_text(edu_setting.description), width: 200 %> <%= edu_setting.created_at&.strftime('%Y-%m-%d %H:%M') %> From ebb1ff76ea7035180ee6f88a3a61c804667b4548 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 9 Oct 2024 17:18:32 +0800 Subject: [PATCH 57/75] =?UTF-8?q?fixed=20=20=E5=90=8E=E5=8F=B0=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E5=88=97=E8=A1=A8=E6=94=AF=E6=8C=81id=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admins/projects_controller.rb | 2 +- app/views/admins/projects/index.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/admins/projects_controller.rb b/app/controllers/admins/projects_controller.rb index f5f210a0d..79582cb7c 100644 --- a/app/controllers/admins/projects_controller.rb +++ b/app/controllers/admins/projects_controller.rb @@ -6,7 +6,7 @@ class Admins::ProjectsController < Admins::BaseController sort_by = Project.column_names.include?(params[:sort_by]) ? params[:sort_by] : 'created_on' sort_direction = %w(desc asc).include?(params[:sort_direction]) ? params[:sort_direction] : 'desc' search = params[:search].to_s.strip - projects = Project.where("name like ? OR identifier LIKE ?", "%#{search}%", "%#{search}%").order("#{sort_by} #{sort_direction}") + projects = Project.where("id = ? OR name like ? OR identifier LIKE ?", search, "%#{search}%", "%#{search}%").order("#{sort_by} #{sort_direction}") case params[:category] when 'public' projects = projects.where(is_public: true) diff --git a/app/views/admins/projects/index.html.erb b/app/views/admins/projects/index.html.erb index be36229fd..bf37a7cb5 100644 --- a/app/views/admins/projects/index.html.erb +++ b/app/views/admins/projects/index.html.erb @@ -4,7 +4,7 @@
    <%= form_tag(admins_projects_path, method: :get, class: 'form-inline search-form flex-1', id: 'project-list-form', remote: true) do %> - <%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '项目名称/标识检索') %> + <%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '项目ID/项目名称/标识检索') %> <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
    From b07fa509e163ccd08a0eb25b3853cc47852019d4 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Thu, 10 Oct 2024 09:38:29 +0800 Subject: [PATCH 58/75] =?UTF-8?q?fixed=20=20=E5=88=A0=E9=99=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=97=B6=E4=BF=9D=E7=95=99=E9=99=84=E4=BB=B6=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 99fd2372d..26a321bcc 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -137,7 +137,7 @@ class User < Owner has_many :tidings, :dependent => :destroy # has_many :journals_for_messages, :as => :jour, :dependent => :destroy - has_many :attachments,foreign_key: :author_id, :dependent => :destroy + has_many :attachments,foreign_key: :author_id has_one :ci_cloud_account, class_name: 'Ci::CloudAccount', dependent: :destroy From 55f3890ccfb9189b0385925162f0a99060fcfaf2 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Thu, 10 Oct 2024 09:57:25 +0800 Subject: [PATCH 59/75] =?UTF-8?q?fixed=20=20=E5=88=A0=E9=99=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=97=B6issue=EF=BC=8Cpr=E7=94=A8=E6=88=B7=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=B7=B2=E6=B3=A8=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/api/v1/issues/journals/_detail.json.jbuilder | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/views/api/v1/issues/journals/_detail.json.jbuilder b/app/views/api/v1/issues/journals/_detail.json.jbuilder index b033579f8..e374dd04c 100644 --- a/app/views/api/v1/issues/journals/_detail.json.jbuilder +++ b/app/views/api/v1/issues/journals/_detail.json.jbuilder @@ -2,12 +2,8 @@ json.id journal.id json.is_journal_detail journal.is_journal_detail? json.created_at journal.created_on.strftime("%Y-%m-%d %H:%M") json.updated_at journal.updated_on.strftime("%Y-%m-%d %H:%M") -json.user do - if journal.user.present? - json.partial! "api/v1/users/simple_user", user: journal.user - else - json.nil! - end +json.user do + json.partial! "api/v1/users/simple_user", user: journal.user end if journal.is_journal_detail? detail = journal.journal_details.take From 382ac02b81dbf58097c770e86512c353e421e6d4 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Thu, 10 Oct 2024 10:09:02 +0800 Subject: [PATCH 60/75] =?UTF-8?q?fixed=20=20=E9=A1=B9=E7=9B=AE=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E5=BC=82=E6=AD=A5=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/cache/v2/project_common_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/cache/v2/project_common_service.rb b/app/services/cache/v2/project_common_service.rb index 1e85f3e08..98a19a80d 100644 --- a/app/services/cache/v2/project_common_service.rb +++ b/app/services/cache/v2/project_common_service.rb @@ -102,7 +102,7 @@ class Cache::V2::ProjectCommonService < ApplicationService return else load_project - return unless @project.is_full_public + return unless @project.present? && @project.is_full_public if @owner_id.present? if $redis_cache.hget(project_common_key, owner_id_key).nil? reset_project_owner_id From bfb3381829a805d2b3d6a8ad12246f3735ac1668 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 11 Oct 2024 08:34:40 +0800 Subject: [PATCH 61/75] =?UTF-8?q?fixed=20=20=E5=88=A0=E9=99=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=97=B6=E4=BF=9D=E7=95=99=E9=A1=B9=E7=9B=AE=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 26a321bcc..1fee098fb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -160,7 +160,7 @@ class User < Owner # 教学案例 # has_many :libraries, dependent: :destroy - has_many :project_trends, dependent: :destroy + has_many :project_trends has_many :oauths , dependent: :destroy has_many :organization_users, dependent: :destroy From 1e82f5ba91f7bb7c79c98c93f19252b44b16e99c Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 11 Oct 2024 08:43:43 +0800 Subject: [PATCH 62/75] =?UTF-8?q?fixed=20=20=E5=88=A0=E9=99=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=97=B6=E4=BF=9D=E7=95=99=E9=A1=B9=E7=9B=AE=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/project_trends/_detail.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/project_trends/_detail.json.jbuilder b/app/views/project_trends/_detail.json.jbuilder index e7c590b8f..3847d3368 100644 --- a/app/views/project_trends/_detail.json.jbuilder +++ b/app/views/project_trends/_detail.json.jbuilder @@ -3,7 +3,7 @@ json.trend_type trend.trend_type json.action_type l("trend.#{trend.action_type}") + l("trend.#{trend.trend_type}") json.trend_id trend.trend_id json.user_name trend.user.try(:show_real_name) -json.user_login trend.user.login +json.user_login trend.user&.login json.user_avatar url_to_avatar(trend.user) json.action_time time_from_now(trend.created_at) json.project do From 7b12526963650dd29f42e9128303ce5813d6975f Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 11 Oct 2024 08:44:51 +0800 Subject: [PATCH 63/75] =?UTF-8?q?fixed=20=20=E5=88=A0=E9=99=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=97=B6=E4=BF=9D=E7=95=99=E9=A1=B9=E7=9B=AE=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/project_trends/_detail.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/project_trends/_detail.json.jbuilder b/app/views/project_trends/_detail.json.jbuilder index 3847d3368..1402a95ff 100644 --- a/app/views/project_trends/_detail.json.jbuilder +++ b/app/views/project_trends/_detail.json.jbuilder @@ -4,7 +4,7 @@ json.action_type l("trend.#{trend.action_type}") + l("trend.#{trend.trend_type}" json.trend_id trend.trend_id json.user_name trend.user.try(:show_real_name) json.user_login trend.user&.login -json.user_avatar url_to_avatar(trend.user) +json.user_avatar trend.user.blank?? User::Avatar.get_letter_avatar_url("D") : url_to_avatar(trend.user) json.action_time time_from_now(trend.created_at) json.project do json.owner do From 28fea9a872a74ab5fb7e275cb684e1815d327bd3 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 11 Oct 2024 08:46:53 +0800 Subject: [PATCH 64/75] =?UTF-8?q?fixed=20=20=E5=88=A0=E9=99=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=97=B6=E4=BF=9D=E7=95=99=E9=A1=B9=E7=9B=AE=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/project_trends/_detail.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/project_trends/_detail.json.jbuilder b/app/views/project_trends/_detail.json.jbuilder index 1402a95ff..55a86768c 100644 --- a/app/views/project_trends/_detail.json.jbuilder +++ b/app/views/project_trends/_detail.json.jbuilder @@ -3,7 +3,7 @@ json.trend_type trend.trend_type json.action_type l("trend.#{trend.action_type}") + l("trend.#{trend.trend_type}") json.trend_id trend.trend_id json.user_name trend.user.try(:show_real_name) -json.user_login trend.user&.login +json.user_login trend.user.blank?? "已注销": trend.user.login json.user_avatar trend.user.blank?? User::Avatar.get_letter_avatar_url("D") : url_to_avatar(trend.user) json.action_time time_from_now(trend.created_at) json.project do From ef64e69aaa782d36f40e8564d1f00ed284a5f7a9 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 11 Oct 2024 08:47:42 +0800 Subject: [PATCH 65/75] =?UTF-8?q?fixed=20=20=E5=88=A0=E9=99=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=97=B6=E4=BF=9D=E7=95=99=E9=A1=B9=E7=9B=AE=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/project_trends/_detail.json.jbuilder | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/project_trends/_detail.json.jbuilder b/app/views/project_trends/_detail.json.jbuilder index 55a86768c..1101083b0 100644 --- a/app/views/project_trends/_detail.json.jbuilder +++ b/app/views/project_trends/_detail.json.jbuilder @@ -2,8 +2,8 @@ json.id trend.id json.trend_type trend.trend_type json.action_type l("trend.#{trend.action_type}") + l("trend.#{trend.trend_type}") json.trend_id trend.trend_id -json.user_name trend.user.try(:show_real_name) -json.user_login trend.user.blank?? "已注销": trend.user.login +json.user_name trend.user.blank?? "已注销": trend.user.show_real_name +json.user_login trend.user&.login json.user_avatar trend.user.blank?? User::Avatar.get_letter_avatar_url("D") : url_to_avatar(trend.user) json.action_time time_from_now(trend.created_at) json.project do From 97d23f8fdcace0f135e7cfcda4323619d32642ca Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 11 Oct 2024 09:01:21 +0800 Subject: [PATCH 66/75] =?UTF-8?q?fixed=20=20=E5=88=A0=E9=99=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=97=B6issue=EF=BC=8Cpr=EF=BC=8C=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=98=BE=E7=A4=BA=E5=B7=B2=E6=B3=A8=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/journals/_journal_item.json.jbuilder | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/journals/_journal_item.json.jbuilder b/app/views/journals/_journal_item.json.jbuilder index 7522d915f..e43f358e4 100644 --- a/app/views/journals/_journal_item.json.jbuilder +++ b/app/views/journals/_journal_item.json.jbuilder @@ -1,7 +1,7 @@ json.id journal.id -json.user_name journal.user.try(:show_real_name) -json.user_login journal.user.try(:login) -json.user_picture url_to_avatar(journal.user) +json.user_name journal.user.blank?? "已注销": journal.user.show_real_name +json.user_login journal.user&.login +json.user_picture journal.user.blank?? User::Avatar.get_letter_avatar_url("D") : url_to_avatar(journal.user) json.is_journal_detail journal.is_journal_detail? #判断是否修改了参数而添加的回复内容 json.content journal.try(:notes) json.journal_details journal.journal_content From 7f93c068b7187739513760513b62a08d1ac97288 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 11 Oct 2024 09:35:57 +0800 Subject: [PATCH 67/75] =?UTF-8?q?fixed=20=E6=9C=AA=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E9=BB=98=E8=AE=A4=E5=A4=B4=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/get_user_info.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/get_user_info.json.jbuilder b/app/views/users/get_user_info.json.jbuilder index 901ea87f0..20b45b1c4 100644 --- a/app/views/users/get_user_info.json.jbuilder +++ b/app/views/users/get_user_info.json.jbuilder @@ -4,7 +4,7 @@ json.nickname @user.nickname json.gender @user.gender json.login @user.login json.user_id @user.id -json.image_url url_to_avatar(@user) +json.image_url url_to_avatar(@user).blank? ? User::Avatar.get_letter_avatar_url("@") : url_to_avatar(@user) json.admin @user.admin? json.is_teacher @user.user_extension&.teacher? json.user_identity @user.identity From 87c8598c4b91bf98b8659db2a80e8124fb898755 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 11 Oct 2024 11:42:04 +0800 Subject: [PATCH 68/75] =?UTF-8?q?fixed=20=20=E5=88=A0=E9=99=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=97=B6=E6=96=87=E6=A1=88=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/users_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index 2ed5072a2..09c5a3276 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -130,7 +130,7 @@ class Api::V1::UsersController < Api::V1::BaseController org_ids = TeamUser.where(user_id: @observe_user.id).pluck(:organization_id) | OrganizationUser.where(user_id: @observe_user.id).pluck(:organization_id) org_count = TeamUser.where(organization_id: org_ids).where(user_id: @observe_user.id).joins(:team).where(teams: {authorize: %w(owner)}).count project_count = Project.where(user_id: @observe_user.id).count - return tip_exception(-1, "当前账号名下存在未删除或退出的组织/仓库,请先删除或退出后再尝试注销操作.") if org_count > 0 || project_count > 0 + return tip_exception(-1, "当前账号名下存在拥有的组织/代码库,请先删除或转让后再尝试注销操作.") if org_count > 0 || project_count > 0 UserAction.create(action_id: @observe_user.id, action_type: "DestroyUser", user_id: @observe_user.id, :ip => request.remote_ip, data_bank: @observe_user.attributes.to_json, memo: params[:memo]) @result_object = Api::V1::Users::DeleteUserService.call(@observe_user) if @result_object From bb7125f2661db08f90d5593823c857df16efd32b Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 11 Oct 2024 14:53:36 +0800 Subject: [PATCH 69/75] =?UTF-8?q?fixed=20=20=E5=88=A0=E9=99=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/images/account/del.svg | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 public/images/account/del.svg diff --git a/public/images/account/del.svg b/public/images/account/del.svg new file mode 100644 index 000000000..2c3420924 --- /dev/null +++ b/public/images/account/del.svg @@ -0,0 +1,6 @@ + + + + + + From c8e9c705f31c3dd03a1bda3e3719e1cb05f01403 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 11 Oct 2024 14:57:06 +0800 Subject: [PATCH 70/75] =?UTF-8?q?fixed=20=20=E5=88=A0=E9=99=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/api/v1/users/_simple_user.json.jbuilder | 2 +- app/views/journals/_journal_item.json.jbuilder | 2 +- app/views/project_trends/_detail.json.jbuilder | 2 +- app/views/pull_requests/index.json.jbuilder | 2 +- app/views/pull_requests/show.json.jbuilder | 2 +- app/views/users/_user_simple.json.jbuilder | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/api/v1/users/_simple_user.json.jbuilder b/app/views/api/v1/users/_simple_user.json.jbuilder index 4d7518bb2..f8ce02617 100644 --- a/app/views/api/v1/users/_simple_user.json.jbuilder +++ b/app/views/api/v1/users/_simple_user.json.jbuilder @@ -8,5 +8,5 @@ else json.name "已注销" json.login user&.login json.type "User" - json.image_url Rails.application.config_for(:configuration)['platform_url'] + "/" + User::Avatar.get_letter_avatar_url("D") + json.image_url Rails.application.config_for(:configuration)['platform_url'] + "/" + "/images/account/del.svg" end \ No newline at end of file diff --git a/app/views/journals/_journal_item.json.jbuilder b/app/views/journals/_journal_item.json.jbuilder index e43f358e4..c8cb71857 100644 --- a/app/views/journals/_journal_item.json.jbuilder +++ b/app/views/journals/_journal_item.json.jbuilder @@ -1,7 +1,7 @@ json.id journal.id json.user_name journal.user.blank?? "已注销": journal.user.show_real_name json.user_login journal.user&.login -json.user_picture journal.user.blank?? User::Avatar.get_letter_avatar_url("D") : url_to_avatar(journal.user) +json.user_picture journal.user.blank?? "/images/account/del.svg" : url_to_avatar(journal.user) json.is_journal_detail journal.is_journal_detail? #判断是否修改了参数而添加的回复内容 json.content journal.try(:notes) json.journal_details journal.journal_content diff --git a/app/views/project_trends/_detail.json.jbuilder b/app/views/project_trends/_detail.json.jbuilder index 1101083b0..2ec03fffe 100644 --- a/app/views/project_trends/_detail.json.jbuilder +++ b/app/views/project_trends/_detail.json.jbuilder @@ -4,7 +4,7 @@ json.action_type l("trend.#{trend.action_type}") + l("trend.#{trend.trend_type}" json.trend_id trend.trend_id json.user_name trend.user.blank?? "已注销": trend.user.show_real_name json.user_login trend.user&.login -json.user_avatar trend.user.blank?? User::Avatar.get_letter_avatar_url("D") : url_to_avatar(trend.user) +json.user_avatar trend.user.blank?? "/images/account/del.svg" : url_to_avatar(trend.user) json.action_time time_from_now(trend.created_at) json.project do json.owner do diff --git a/app/views/pull_requests/index.json.jbuilder b/app/views/pull_requests/index.json.jbuilder index b648d8bae..78ba87662 100644 --- a/app/views/pull_requests/index.json.jbuilder +++ b/app/views/pull_requests/index.json.jbuilder @@ -37,7 +37,7 @@ json.issues do json.assign_user_login issue.get_assign_user.try(:login) json.author_name issue.user.blank?? "已注销": issue.user.show_real_name json.author_login issue.user.try(:login) - json.avatar_url issue.user.blank?? User::Avatar.get_letter_avatar_url("D") : url_to_avatar(issue.user) + json.avatar_url issue.user.blank?? "/images/account/del.svg" : url_to_avatar(issue.user) json.priority issue.priority.try(:name) json.version issue.version.try(:name) json.journals_count issue.get_journals_size diff --git a/app/views/pull_requests/show.json.jbuilder b/app/views/pull_requests/show.json.jbuilder index 7420a7c37..18db8082a 100644 --- a/app/views/pull_requests/show.json.jbuilder +++ b/app/views/pull_requests/show.json.jbuilder @@ -46,7 +46,7 @@ json.issue do json.assign_user_login @issue_assign_to.try(:login) json.author_name @issue_user.blank?? "已注销": @issue_user.show_real_name json.author_login @issue_user.try(:login) - json.author_picture @issue_user.blank?? User::Avatar.get_letter_avatar_url("D") : url_to_avatar(@issue_user) + json.author_picture @issue_user.blank?? "/images/account/del.svg" : url_to_avatar(@issue_user) json.issue_status @issue.issue_status.try(:name) json.priority @issue.priority.try(:name) json.version @issue.version.try(:name) diff --git a/app/views/users/_user_simple.json.jbuilder b/app/views/users/_user_simple.json.jbuilder index 2fa5c2717..9739f730a 100644 --- a/app/views/users/_user_simple.json.jbuilder +++ b/app/views/users/_user_simple.json.jbuilder @@ -8,5 +8,5 @@ else json.name "已注销" json.login user&.login json.type "User" - json.image_url Rails.application.config_for(:configuration)['platform_url'] + "/" + User::Avatar.get_letter_avatar_url("D") + json.image_url Rails.application.config_for(:configuration)['platform_url'] + "/" + "/images/account/del.svg" end \ No newline at end of file From 098b045315e029a07eb2c9283c1bd5d8b1a0688a Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 11 Oct 2024 15:01:32 +0800 Subject: [PATCH 71/75] =?UTF-8?q?fixed=20=20=E5=88=A0=E9=99=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/api/v1/users/_simple_user.json.jbuilder | 2 +- app/views/journals/_journal_item.json.jbuilder | 2 +- app/views/project_trends/_detail.json.jbuilder | 2 +- app/views/pull_requests/index.json.jbuilder | 2 +- app/views/pull_requests/show.json.jbuilder | 2 +- app/views/users/_user_simple.json.jbuilder | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/api/v1/users/_simple_user.json.jbuilder b/app/views/api/v1/users/_simple_user.json.jbuilder index f8ce02617..e1696ab93 100644 --- a/app/views/api/v1/users/_simple_user.json.jbuilder +++ b/app/views/api/v1/users/_simple_user.json.jbuilder @@ -8,5 +8,5 @@ else json.name "已注销" json.login user&.login json.type "User" - json.image_url Rails.application.config_for(:configuration)['platform_url'] + "/" + "/images/account/del.svg" + json.image_url Rails.application.config_for(:configuration)['platform_url'] + "/" + "images/account/del.svg" end \ No newline at end of file diff --git a/app/views/journals/_journal_item.json.jbuilder b/app/views/journals/_journal_item.json.jbuilder index c8cb71857..0d58892ab 100644 --- a/app/views/journals/_journal_item.json.jbuilder +++ b/app/views/journals/_journal_item.json.jbuilder @@ -1,7 +1,7 @@ json.id journal.id json.user_name journal.user.blank?? "已注销": journal.user.show_real_name json.user_login journal.user&.login -json.user_picture journal.user.blank?? "/images/account/del.svg" : url_to_avatar(journal.user) +json.user_picture journal.user.blank?? "images/account/del.svg" : url_to_avatar(journal.user) json.is_journal_detail journal.is_journal_detail? #判断是否修改了参数而添加的回复内容 json.content journal.try(:notes) json.journal_details journal.journal_content diff --git a/app/views/project_trends/_detail.json.jbuilder b/app/views/project_trends/_detail.json.jbuilder index 2ec03fffe..b9febc107 100644 --- a/app/views/project_trends/_detail.json.jbuilder +++ b/app/views/project_trends/_detail.json.jbuilder @@ -4,7 +4,7 @@ json.action_type l("trend.#{trend.action_type}") + l("trend.#{trend.trend_type}" json.trend_id trend.trend_id json.user_name trend.user.blank?? "已注销": trend.user.show_real_name json.user_login trend.user&.login -json.user_avatar trend.user.blank?? "/images/account/del.svg" : url_to_avatar(trend.user) +json.user_avatar trend.user.blank?? "images/account/del.svg" : url_to_avatar(trend.user) json.action_time time_from_now(trend.created_at) json.project do json.owner do diff --git a/app/views/pull_requests/index.json.jbuilder b/app/views/pull_requests/index.json.jbuilder index 78ba87662..9f371cb21 100644 --- a/app/views/pull_requests/index.json.jbuilder +++ b/app/views/pull_requests/index.json.jbuilder @@ -37,7 +37,7 @@ json.issues do json.assign_user_login issue.get_assign_user.try(:login) json.author_name issue.user.blank?? "已注销": issue.user.show_real_name json.author_login issue.user.try(:login) - json.avatar_url issue.user.blank?? "/images/account/del.svg" : url_to_avatar(issue.user) + json.avatar_url issue.user.blank?? "images/account/del.svg" : url_to_avatar(issue.user) json.priority issue.priority.try(:name) json.version issue.version.try(:name) json.journals_count issue.get_journals_size diff --git a/app/views/pull_requests/show.json.jbuilder b/app/views/pull_requests/show.json.jbuilder index 18db8082a..304457f82 100644 --- a/app/views/pull_requests/show.json.jbuilder +++ b/app/views/pull_requests/show.json.jbuilder @@ -46,7 +46,7 @@ json.issue do json.assign_user_login @issue_assign_to.try(:login) json.author_name @issue_user.blank?? "已注销": @issue_user.show_real_name json.author_login @issue_user.try(:login) - json.author_picture @issue_user.blank?? "/images/account/del.svg" : url_to_avatar(@issue_user) + json.author_picture @issue_user.blank?? "images/account/del.svg" : url_to_avatar(@issue_user) json.issue_status @issue.issue_status.try(:name) json.priority @issue.priority.try(:name) json.version @issue.version.try(:name) diff --git a/app/views/users/_user_simple.json.jbuilder b/app/views/users/_user_simple.json.jbuilder index 9739f730a..30343d75e 100644 --- a/app/views/users/_user_simple.json.jbuilder +++ b/app/views/users/_user_simple.json.jbuilder @@ -8,5 +8,5 @@ else json.name "已注销" json.login user&.login json.type "User" - json.image_url Rails.application.config_for(:configuration)['platform_url'] + "/" + "/images/account/del.svg" + json.image_url Rails.application.config_for(:configuration)['platform_url'] + "/" + "images/account/del.svg" end \ No newline at end of file From 8bf6f24fe6492482416d0f14f56d10ed2ebe4f9f Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 11 Oct 2024 15:35:40 +0800 Subject: [PATCH 72/75] =?UTF-8?q?fixed=20=20=E5=88=A0=E9=99=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=97=B6issue=EF=BC=8Cpr=EF=BC=8C=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=98=BE=E7=A4=BA=E5=B7=B2=E6=B3=A8=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/version_releases/_version_release.json.jbuilder | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/version_releases/_version_release.json.jbuilder b/app/views/version_releases/_version_release.json.jbuilder index 9835db152..83bfd8e1f 100644 --- a/app/views/version_releases/_version_release.json.jbuilder +++ b/app/views/version_releases/_version_release.json.jbuilder @@ -11,9 +11,9 @@ json.zipball_url render_zip_url(@owner, @repository, version&.tag_name) json.draft version&.draft ? "草稿" : (version&.prerelease ? "预发行" : "稳定") json.created_at format_time(version.created_at.to_s.to_time) json.published_at format_time(version.created_at.to_s.to_time) -json.user_name user.present? ? user.try(:show_real_name) : "" +json.user_name user.present? ? user.try(:show_real_name) : "已注销" json.user_login user&.login -json.image_url user.present? ? url_to_avatar(user) : "" +json.image_url user.present? ? url_to_avatar(user) : "images/account/del.svg" json.attachments do json.array! version.try(:attachments) do |attachment| # json.partial! "attachments/attachment_simple", locals: {attachment: attachment} From 9ac8bac7774b3b4c0f636343da58942fc7cbeaf1 Mon Sep 17 00:00:00 2001 From: yystopf Date: Sat, 12 Oct 2024 14:54:01 +0800 Subject: [PATCH 73/75] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=9B=B4?= =?UTF-8?q?=E6=96=B0issue=20protrend=E6=9C=AA=E6=AD=A3=E5=B8=B8=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/api/pm/issues/update_service.rb | 2 +- app/services/api/v1/issues/update_service.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/api/pm/issues/update_service.rb b/app/services/api/pm/issues/update_service.rb index 78d62fb2b..bfce0430e 100644 --- a/app/services/api/pm/issues/update_service.rb +++ b/app/services/api/pm/issues/update_service.rb @@ -64,7 +64,6 @@ class Api::Pm::Issues::UpdateService < ApplicationService build_assigner_issue_journal_details unless assigner_ids.nil?# 操作记录 build_attachment_issue_journal_details unless attachment_ids.nil? build_issue_tag_issue_journal_details unless issue_tag_ids.nil? - build_issue_project_trends if status_id.present? # 开关时间记录 build_assigner_participants unless assigner_ids.nil? # 负责人 build_edit_participants build_atme_participants if @atme_receivers.present? @@ -92,6 +91,7 @@ class Api::Pm::Issues::UpdateService < ApplicationService build_after_issue_journal_details if @updated_issue.previous_changes.present? # 操作记录 build_previous_issue_changes + build_issue_project_trends if status_id.present? # 开关时间记录 build_cirle_blockchain_token if blockchain_token_num.present? unless @project.id.zero? # @信息发送 diff --git a/app/services/api/v1/issues/update_service.rb b/app/services/api/v1/issues/update_service.rb index 5f040b25f..935eb3b2f 100644 --- a/app/services/api/v1/issues/update_service.rb +++ b/app/services/api/v1/issues/update_service.rb @@ -64,7 +64,6 @@ class Api::V1::Issues::UpdateService < ApplicationService build_assigner_issue_journal_details unless assigner_ids.nil?# 操作记录 build_attachment_issue_journal_details unless attachment_ids.nil? build_issue_tag_issue_journal_details unless issue_tag_ids.nil? - build_issue_project_trends if status_id.present? # 开关时间记录 build_assigner_participants unless assigner_ids.nil? # 负责人 build_edit_participants build_atme_participants if @atme_receivers.present? @@ -92,6 +91,7 @@ class Api::V1::Issues::UpdateService < ApplicationService build_after_issue_journal_details if @updated_issue.previous_changes.present? # 操作记录 build_previous_issue_changes + build_issue_project_trends if status_id.present? # 开关时间记录 build_cirle_blockchain_token if blockchain_token_num.present? unless @project.id.zero? # @信息发送 From 359f1c40f604587e6cb6e68ff77007e5c01f461e Mon Sep 17 00:00:00 2001 From: yystopf Date: Sat, 12 Oct 2024 15:03:43 +0800 Subject: [PATCH 74/75] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=9B=B4?= =?UTF-8?q?=E6=96=B0issue=20protrend=E6=9C=AA=E6=AD=A3=E5=B8=B8=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/api/pm/issues/update_service.rb | 2 +- app/services/api/v1/issues/update_service.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/api/pm/issues/update_service.rb b/app/services/api/pm/issues/update_service.rb index bfce0430e..661bd211f 100644 --- a/app/services/api/pm/issues/update_service.rb +++ b/app/services/api/pm/issues/update_service.rb @@ -172,7 +172,7 @@ class Api::Pm::Issues::UpdateService < ApplicationService def build_issue_project_trends if @updated_issue.previous_changes["status_id"].present? && @updated_issue.previous_changes["status_id"][1] == 5 - @updated_issue.project_trends.new({user_id: current_user.id, project_id: @project.id, action_type: ProjectTrend::CLOSE}) + @updated_issue.project_trends.create!({user_id: current_user.id, project_id: @project.id, action_type: ProjectTrend::CLOSE}) end if @updated_issue.previous_changes["status_id"].present? && @updated_issue.previous_changes["status_id"][0] == 5 @updated_issue.project_trends.where(action_type: ProjectTrend::CLOSE).each(&:destroy!) diff --git a/app/services/api/v1/issues/update_service.rb b/app/services/api/v1/issues/update_service.rb index 935eb3b2f..10f814300 100644 --- a/app/services/api/v1/issues/update_service.rb +++ b/app/services/api/v1/issues/update_service.rb @@ -172,7 +172,7 @@ class Api::V1::Issues::UpdateService < ApplicationService def build_issue_project_trends if @updated_issue.previous_changes["status_id"].present? && @updated_issue.previous_changes["status_id"][1] == 5 - @updated_issue.project_trends.new({user_id: current_user.id, project_id: @project.id, action_type: ProjectTrend::CLOSE}) + @updated_issue.project_trends.create!({user_id: current_user.id, project_id: @project.id, action_type: ProjectTrend::CLOSE}) end if @updated_issue.previous_changes["status_id"].present? && @updated_issue.previous_changes["status_id"][0] == 5 @updated_issue.project_trends.where(action_type: ProjectTrend::CLOSE).each(&:destroy!) From bd0e456b9fa7ca2e0dbb07dcace18094ba89542b Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 14 Oct 2024 11:56:07 +0800 Subject: [PATCH 75/75] =?UTF-8?q?=E8=84=9A=E6=9C=AC=EF=BC=9A=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=88=90=E5=91=98=E7=94=A8=E6=88=B7=E5=88=B0=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E4=BB=93=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/batch_user_add_projects.rake | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lib/tasks/batch_user_add_projects.rake diff --git a/lib/tasks/batch_user_add_projects.rake b/lib/tasks/batch_user_add_projects.rake new file mode 100644 index 000000000..c2158117b --- /dev/null +++ b/lib/tasks/batch_user_add_projects.rake @@ -0,0 +1,25 @@ +namespace :batch_user_add_projects do + desc "batch add projects" + task done: :environment do + user_id = ENV['user_id'] + puts "user_id=================#{user_id}" + next if user_id.blank? + project_ids = Project.find_by_sql("SELECT id FROM projects WHERE forked_from_project_id IN (SELECT id FROM projects WHERE user_id IN (SELECT id FROM users WHERE login='OSKYCX'))").pluck(:id) + if ENV['project_id'].present? + project_ids = [ENV['project_id']] + end + next if project_ids.blank? + puts "project_ids=================#{project_ids}" + project_ids.each do |project_id| + begin + user = User.find_by(id: user_id) + next if user.blank? + project = Project.find_by(id: project_id) + next if project.blank? + Projects::AddMemberInteractor.call(project.owner, project, user, "admin") + rescue Exception => e + puts "batch add projects error: #{user_id}" + end + end + end +end \ No newline at end of file