工单修改后,创建的为工单用户的bug

This commit is contained in:
sylor_huang@126.com 2020-04-28 10:41:20 +08:00
parent e1ad8d7764
commit c35156e487
7 changed files with 56 additions and 17 deletions

View File

@ -60,6 +60,8 @@ group :development, :test do
end end
group :development do group :development do
gem 'rubocop', '~> 0.52.0'
gem 'solargraph', '~> 0.38.0'
gem 'awesome_print' gem 'awesome_print'
gem 'web-console', '>= 3.3.0' gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2' gem 'listen', '>= 3.0.5', '< 3.2'

View File

@ -64,6 +64,7 @@ GEM
archive-zip (0.12.0) archive-zip (0.12.0)
io-like (~> 0.3.0) io-like (~> 0.3.0)
arel (9.0.0) arel (9.0.0)
ast (2.4.0)
autoprefixer-rails (9.7.4) autoprefixer-rails (9.7.4)
execjs execjs
awesome_print (1.8.0) awesome_print (1.8.0)
@ -75,6 +76,8 @@ GEM
axlsx_rails (0.5.2) axlsx_rails (0.5.2)
actionpack (>= 3.1) actionpack (>= 3.1)
axlsx (>= 2.0.1) axlsx (>= 2.0.1)
backport (1.1.2)
benchmark (0.1.0)
bindex (0.8.1) bindex (0.8.1)
bootsnap (1.4.6) bootsnap (1.4.6)
msgpack (~> 1.0) msgpack (~> 1.0)
@ -107,6 +110,7 @@ GEM
activerecord (>= 3.1.0, < 7) activerecord (>= 3.1.0, < 7)
diff-lcs (1.3) diff-lcs (1.3)
diffy (3.3.0) diffy (3.3.0)
e2mmap (0.1.0)
elasticsearch (7.5.0) elasticsearch (7.5.0)
elasticsearch-api (= 7.5.0) elasticsearch-api (= 7.5.0)
elasticsearch-transport (= 7.5.0) elasticsearch-transport (= 7.5.0)
@ -140,6 +144,7 @@ GEM
i18n (1.8.2) i18n (1.8.2)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
io-like (0.3.1) io-like (0.3.1)
jaro_winkler (1.5.4)
jbuilder (2.10.0) jbuilder (2.10.0)
activesupport (>= 5.0.0) activesupport (>= 5.0.0)
jquery-rails (4.3.5) jquery-rails (4.3.5)
@ -170,6 +175,7 @@ GEM
mini_mime (>= 0.1.1) mini_mime (>= 0.1.1)
marcel (0.3.3) marcel (0.3.3)
mimemagic (~> 0.3.2) mimemagic (~> 0.3.2)
maruku (0.7.3)
method_source (0.9.2) method_source (0.9.2)
mime-types (3.3.1) mime-types (3.3.1)
mime-types-data (~> 3.2015) mime-types-data (~> 3.2015)
@ -205,8 +211,11 @@ GEM
oauth2 (~> 1.1) oauth2 (~> 1.1)
omniauth (~> 1.9) omniauth (~> 1.9)
parallel (1.19.1) parallel (1.19.1)
parser (2.7.1.1)
ast (~> 2.4.0)
pdfkit (0.8.4.1) pdfkit (0.8.4.1)
popper_js (1.16.0) popper_js (1.16.0)
powerpack (0.1.2)
public_suffix (4.0.3) public_suffix (4.0.3)
puma (3.12.2) puma (3.12.2)
rack (2.0.9) rack (2.0.9)
@ -243,6 +252,7 @@ GEM
method_source method_source
rake (>= 0.8.7) rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0) thor (>= 0.19.0, < 2.0)
rainbow (3.0.0)
rake (13.0.1) rake (13.0.1)
rb-fsevent (0.10.3) rb-fsevent (0.10.3)
rb-inotify (0.10.1) rb-inotify (0.10.1)
@ -269,6 +279,8 @@ GEM
regexp_parser (1.7.0) regexp_parser (1.7.0)
request_store (1.5.0) request_store (1.5.0)
rack (>= 1.4) rack (>= 1.4)
reverse_markdown (1.4.0)
nokogiri
roo (2.8.3) roo (2.8.3)
nokogiri (~> 1) nokogiri (~> 1)
rubyzip (>= 1.3.0, < 3.0.0) rubyzip (>= 1.3.0, < 3.0.0)
@ -298,7 +310,15 @@ GEM
rspec-mocks (~> 3.9.0) rspec-mocks (~> 3.9.0)
rspec-support (~> 3.9.0) rspec-support (~> 3.9.0)
rspec-support (3.9.2) rspec-support (3.9.2)
rubocop (0.52.1)
parallel (~> 1.10)
parser (>= 2.4.0.2, < 3.0)
powerpack (~> 0.1)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-ole (1.2.12.2) ruby-ole (1.2.12.2)
ruby-progressbar (1.10.1)
ruby2_keywords (0.0.2) ruby2_keywords (0.0.2)
ruby_dep (1.5.0) ruby_dep (1.5.0)
rubyzip (1.3.0) rubyzip (1.3.0)
@ -344,6 +364,20 @@ GEM
rack (~> 2.0) rack (~> 2.0)
rack-protection (= 2.0.8.1) rack-protection (= 2.0.8.1)
tilt (~> 2.0) tilt (~> 2.0)
solargraph (0.38.6)
backport (~> 1.1)
benchmark
bundler (>= 1.17.2)
e2mmap
jaro_winkler (~> 1.5)
maruku (~> 0.7, >= 0.7.3)
nokogiri (~> 1.9, >= 1.9.1)
parser (~> 2.3)
reverse_markdown (~> 1.0, >= 1.0.5)
rubocop (~> 0.52)
thor (~> 1.0)
tilt (~> 2.0)
yard (~> 0.9)
spreadsheet (1.2.6) spreadsheet (1.2.6)
ruby-ole (>= 1.0) ruby-ole (>= 1.0)
spring (2.0.2) spring (2.0.2)
@ -382,6 +416,7 @@ GEM
wkhtmltopdf-binary (0.12.5.4) wkhtmltopdf-binary (0.12.5.4)
xpath (3.2.0) xpath (3.2.0)
nokogiri (~> 1.8) nokogiri (~> 1.8)
yard (0.9.24)
PLATFORMS PLATFORMS
ruby ruby
@ -434,6 +469,7 @@ DEPENDENCIES
rqrcode (~> 0.10.1) rqrcode (~> 0.10.1)
rqrcode_png rqrcode_png
rspec-rails (~> 3.8) rspec-rails (~> 3.8)
rubocop (~> 0.52.0)
ruby-ole ruby-ole
rubyzip rubyzip
sass-rails (~> 5.0) sass-rails (~> 5.0)
@ -443,6 +479,7 @@ DEPENDENCIES
simple_form simple_form
simple_xlsx_reader simple_xlsx_reader
sinatra sinatra
solargraph (~> 0.38.0)
spreadsheet spreadsheet
spring spring
spring-watcher-listen (~> 2.0.0) spring-watcher-listen (~> 2.0.0)

View File

@ -11,7 +11,7 @@ class IssueDependsController < ApplicationController
} }
save_issue_depend = IssueDepend.new(issue_depend) save_issue_depend = IssueDepend.new(issue_depend)
if save_issue_depend.save if save_issue_depend.save
@issue.custom_journal_detail("issue_depend","", @issue.id) @issue.custom_journal_detail("issue_depend","", @issue.id, current_user&.id)
normal_status(0, "添加依赖成功") normal_status(0, "添加依赖成功")
else else
normal_status(0, "添加依赖失败") normal_status(0, "添加依赖失败")
@ -23,7 +23,7 @@ class IssueDependsController < ApplicationController
depend_issue_params = params[:id] depend_issue_params = params[:id]
depend_issue = IssueDepend.find(depend_issue_params) depend_issue = IssueDepend.find(depend_issue_params)
if depend_issue&.destroy if depend_issue&.destroy
@issue.custom_journal_detail("destroy_issue_depend","", @issue.id) @issue.custom_journal_detail("destroy_issue_depend","", @issue.id, current_user&.id)
normal_status(0, "删除依赖成功") normal_status(0, "删除依赖成功")
else else
normal_status(-1, "删除依赖失败") normal_status(-1, "删除依赖失败")

View File

@ -11,7 +11,7 @@ class IssueTimesController < ApplicationController
} }
save_issue_time = IssueTime.new(issue_time) save_issue_time = IssueTime.new(issue_time)
if save_issue_time.save if save_issue_time.save
@issue.custom_journal_detail("work_time",save_issue_time.id, "开始工作") @issue.custom_journal_detail("work_time",save_issue_time.id, "开始工作", current_user&.id)
normal_status(0, "开始成功") normal_status(0, "开始成功")
else else
normal_status(0, "开始失败") normal_status(0, "开始失败")
@ -27,10 +27,10 @@ class IssueTimesController < ApplicationController
if last_work_time.update_all(end_time: end_work_time) if last_work_time.update_all(end_time: end_work_time)
if end_type == 0 if end_type == 0
message = "取消时间跟踪" message = "取消时间跟踪"
@issue.custom_journal_detail("cancel_time",last_work_time&.first.try(:id), "取消时间跟踪") @issue.custom_journal_detail("cancel_time",last_work_time&.first.try(:id), "取消时间跟踪", current_user&.id)
else else
message = "停止工作" message = "停止工作"
@issue.custom_journal_detail("end_time",last_work_time&.first.try(:id), "停止工作") @issue.custom_journal_detail("end_time",last_work_time&.first.try(:id), "停止工作", current_user&.id)
end end
normal_status(0, message) normal_status(0, message)
else else

View File

@ -268,7 +268,7 @@ class IssuesController < ApplicationController
@issue.issue_times.update_all(end_time: Time.now) @issue.issue_times.update_all(end_time: Time.now)
end end
@issue.create_journal_detail(change_files, issue_files, issue_file_ids) @issue.create_journal_detail(change_files, issue_files, issue_file_ids, current_user&.id)
normal_status(0, "更新成功") normal_status(0, "更新成功")
else else
normal_status(-1, "更新失败") normal_status(-1, "更新失败")
@ -338,7 +338,7 @@ class IssuesController < ApplicationController
else else
close_message = "close_pr" close_message = "close_pr"
end end
@issue.custom_journal_detail(close_message,old_message, "#{message}") @issue.custom_journal_detail(close_message,old_message, "#{message}", current_user&.id)
normal_status(0, message) normal_status(0, message)
else else
@ -351,9 +351,9 @@ class IssuesController < ApplicationController
type = (params[:lock_type].to_i == 1) type = (params[:lock_type].to_i == 1)
if @issue.update_attribute(:is_lock, type) if @issue.update_attribute(:is_lock, type)
if type if type
@issue.custom_journal_detail("lock_issue","", "因为#{params[:lock_reason].present? ? params[:lock_reason].to_s : "某种原因"}而锁定,并将对话限制为协作者") @issue.custom_journal_detail("lock_issue","", "因为#{params[:lock_reason].present? ? params[:lock_reason].to_s : "某种原因"}而锁定,并将对话限制为协作者", current_user&.id)
else else
@issue.custom_journal_detail("unlock_issue","", "解除锁定") @issue.custom_journal_detail("unlock_issue","", "解除锁定", current_user&.id)
end end
normal_status(0, "操作成功") normal_status(0, "操作成功")
else else

View File

@ -138,7 +138,7 @@ class PullRequestsController < ApplicationController
end end
local_requests.project_trends.create(user_id: current_user.id, project_id: @project.id, action_type: "create") local_requests.project_trends.create(user_id: current_user.id, project_id: @project.id, action_type: "create")
if params[:title].to_s.include?("WIP:") if params[:title].to_s.include?("WIP:")
pull_issue.custom_journal_detail("WIP", "", "这个合并请求被标记为尚未完成的工作。完成后请从标题中移除WIP:前缀。") pull_issue.custom_journal_detail("WIP", "", "这个合并请求被标记为尚未完成的工作。完成后请从标题中移除WIP:前缀。", current_user&.id)
end end
normal_status(0, "PullRequest创建成功") normal_status(0, "PullRequest创建成功")
else else
@ -224,7 +224,7 @@ class PullRequestsController < ApplicationController
if params[:status_id].to_i == 5 if params[:status_id].to_i == 5
@issue.issue_times.update_all(end_time: Time.now) @issue.issue_times.update_all(end_time: Time.now)
end end
@issue.create_journal_detail(change_files, issue_files, issue_file_ids) @issue.create_journal_detail(change_files, issue_files, issue_file_ids, current_user&.id)
normal_status(0, "PullRequest更新成功") normal_status(0, "PullRequest更新成功")
else else
normal_status(-1, "PullRequest更新失败") normal_status(-1, "PullRequest更新失败")
@ -306,7 +306,7 @@ class PullRequestsController < ApplicationController
# @pull_request.project_trends.create(user_id: current_user.id, project_id: @project.id, action_type: "merge") # @pull_request.project_trends.create(user_id: current_user.id, project_id: @project.id, action_type: "merge")
@pull_request&.project_trends&.update_all(action_type: "close") @pull_request&.project_trends&.update_all(action_type: "close")
@issue&.custom_journal_detail("merge", "", "该合并请求已被合并") @issue&.custom_journal_detail("merge", "", "该合并请求已被合并", current_user&.id)
normal_status(1, "合并成功") normal_status(1, "合并成功")
else else
normal_status(-1, "合并失败") normal_status(-1, "合并失败")
@ -357,7 +357,7 @@ class PullRequestsController < ApplicationController
if merge_pr if merge_pr
@pull_request&.project_trends&.update_all(action_type: "close") @pull_request&.project_trends&.update_all(action_type: "close")
# @pull_request.project_trends.create(user_id: current_user.id, project_id: @project.id, action_type: "merge") # @pull_request.project_trends.create(user_id: current_user.id, project_id: @project.id, action_type: "merge")
@issue.custom_journal_detail("merge", "", "该合并请求已被合并") @issue.custom_journal_detail("merge", "", "该合并请求已被合并", current_user&.id)
normal_status(1, "评审成功") normal_status(1, "评审成功")
else else
normal_status(-1, "评审失败") normal_status(-1, "评审失败")

View File

@ -30,9 +30,9 @@ class Issue < ApplicationRecord
User.select(:login, :lastname,:firstname, :nickname)&.find_by_id(self.assigned_to_id) User.select(:login, :lastname,:firstname, :nickname)&.find_by_id(self.assigned_to_id)
end end
def create_journal_detail(change_files, issue_files, issue_file_ids) def create_journal_detail(change_files, issue_files, issue_file_ids, user_id)
journal_params = { journal_params = {
journalized_id: self.id, journalized_type: "Issue", user_id: self.author_id journalized_id: self.id, journalized_type: "Issue", user_id: user_id
} }
journal = Journal.new journal_params journal = Journal.new journal_params
@ -51,9 +51,9 @@ class Issue < ApplicationRecord
end end
end end
def custom_journal_detail(prop_key, old_value, value) def custom_journal_detail(prop_key, old_value, value, user_id)
journal_params = { journal_params = {
journalized_id: self.id, journalized_type: "Issue", user_id: self.author_id journalized_id: self.id, journalized_type: "Issue", user_id: user_id
} }
journal = Journal.new journal_params journal = Journal.new journal_params
if journal.save if journal.save