diff --git a/app/models/project_actions/fork_event.rb b/app/models/project_actions/fork_event.rb
index 0d9bb99b0..c6815533a 100644
--- a/app/models/project_actions/fork_event.rb
+++ b/app/models/project_actions/fork_event.rb
@@ -24,7 +24,7 @@ class ProjectActions::ForkEvent < ProjectAction
forkee_name: fork_project.identifier,
forkee_owner_id: fork_project.owner.id,
forkee_owner_login: fork_project.owner.login
- }
+ }.as_json
project_action.save!
end
end
diff --git a/app/models/project_actions/issue_comment_event.rb b/app/models/project_actions/issue_comment_event.rb
index 2a5a73fdd..46e2bbe63 100644
--- a/app/models/project_actions/issue_comment_event.rb
+++ b/app/models/project_actions/issue_comment_event.rb
@@ -23,7 +23,7 @@ class ProjectActions::IssueCommentEvent < ProjectAction
issue_id: issue.id,
issue_number: issue.project_issues_index,
body: journal.notes
- }
+ }.as_json
project_action.save!
end
end
diff --git a/app/models/project_actions/issues_event.rb b/app/models/project_actions/issues_event.rb
index a51536a35..fba70e798 100644
--- a/app/models/project_actions/issues_event.rb
+++ b/app/models/project_actions/issues_event.rb
@@ -27,7 +27,7 @@ class ProjectActions::IssuesEvent < ProjectAction
title: issue.subject,
body: issue.description,
action: action
- }
+ }.as_json
project_action.save!
end
end
diff --git a/app/models/project_actions/pull_request_event.rb b/app/models/project_actions/pull_request_event.rb
index b27e43c41..b7846e723 100644
--- a/app/models/project_actions/pull_request_event.rb
+++ b/app/models/project_actions/pull_request_event.rb
@@ -25,8 +25,8 @@ class ProjectActions::PullRequestEvent < ProjectAction
pull_id: pull_request.id,
pull_number: pull_request.gitea_number,
title: pull_request.title,
- body: pull_request.body,
- git_diff: gitea_pull_request,
+ # body: pull_request.body,
+ # git_diff: gitea_pull_request,
additions: gitea_pull_request['TotalAddition'],
deletions: gitea_pull_request['TotalDeletion'],
changed_files: gitea_pull_request['NumFiles'],
@@ -35,7 +35,7 @@ class ProjectActions::PullRequestEvent < ProjectAction
head_repo_id: pull_request.is_original ? pull_request.fork_project_id : pull_request.project_id,
head_repo_name: pull_request.project&.identifier,
head_ref: pull_request.head
- }
+ }.as_json
project_action.save!
end
end
diff --git a/app/models/project_actions/pull_request_review_comment_event.rb b/app/models/project_actions/pull_request_review_comment_event.rb
index a1a2fa0f6..22a6677a4 100644
--- a/app/models/project_actions/pull_request_review_comment_event.rb
+++ b/app/models/project_actions/pull_request_review_comment_event.rb
@@ -23,7 +23,7 @@ class ProjectActions::PullRequestReviewCommentEvent < ProjectAction
pull_id: pull_request.id,
pull_number: pull_request.gitea_number,
body: journal.notes
- }
+ }.as_json
project_action.save!
end
end
diff --git a/app/models/project_actions/release_event.rb b/app/models/project_actions/release_event.rb
index 2505d1603..9a46f94c3 100644
--- a/app/models/project_actions/release_event.rb
+++ b/app/models/project_actions/release_event.rb
@@ -23,7 +23,7 @@ class ProjectActions::ReleaseEvent < ProjectAction
tag_name: version_release.tag_name,
name: version_release.name,
body: version_release.body
- }
+ }.as_json
project_action.save!
end
end
diff --git a/app/models/user_action.rb b/app/models/user_action.rb
index 0dba93da4..d0a5a6605 100644
--- a/app/models/user_action.rb
+++ b/app/models/user_action.rb
@@ -25,6 +25,8 @@
class UserAction < ApplicationRecord
+ belongs_to :user, optional: true
+
after_save :add_user_info
serialize :data_bank, JSON
@@ -36,6 +38,7 @@ class UserAction < ApplicationRecord
when "Login" then "登录"
when "Logout" then "退出登录"
when "DestroyOrganization" then "删除组织"
+ when "Attachment" then "上传附件"
else self.action_type
end
end
@@ -43,7 +46,7 @@ class UserAction < ApplicationRecord
def opt_user_name
user = User.find_by(id: self.user_id)
if user.present?
- user&.login
+ user&.real_name
else
del_user = UserAction.find_by(action_type: "DestroyUser", action_id: self.user_id)
del_user.present? ? del_user.user.login : "不存在用户:#{user_id}"
@@ -55,6 +58,13 @@ class UserAction < ApplicationRecord
when "DestroyUser" then "账号:#{user&.login}
邮箱:#{user&.mail}
手机号:#{user&.phone}
昵称:#{user&.nickname}
"
when "DestroyProject" then "项目名称:#{project&.name}
项目标识:#{project&.identifier}
"
when "DestroyOrganization" then "组织名称:#{organization&.nickname}
组织标识:#{organization&.login}
"
+ when 'Attachment'
+ issue = Issue.find_by_id(attachment.container_id)
+ if attachment.container_type == "Issue" && issue&.issue_classify == "issue"
+ return "上传附件issue地址:#{issue&.subject}"
+ else
+ return "上传附件地址:#{attachment.title}"
+ end
else "--"
end
end
@@ -86,6 +96,15 @@ class UserAction < ApplicationRecord
action_organization
end
+ def attachment
+ action_attachment = if action_type == "Attachment" && data_bank.present?
+ build_mode("Attachment")
+ else
+ Attachment.find_by(id: self.action_id)
+ end
+ action_attachment
+ end
+
def build_mode(model_name)
model = model_name.constantize.new
diff --git a/app/views/admins/user_actions/index.html.erb b/app/views/admins/user_actions/index.html.erb
index 3be99282a..371633b58 100644
--- a/app/views/admins/user_actions/index.html.erb
+++ b/app/views/admins/user_actions/index.html.erb
@@ -5,9 +5,9 @@