From 50dc5cce5dd0dd5e0a4588bd148c15e35af9a412 Mon Sep 17 00:00:00 2001 From: yystopf Date: Sat, 7 May 2022 14:06:48 +0800 Subject: [PATCH] fix --- app/controllers/issues_controller.rb | 4 ++-- app/controllers/journals_controller.rb | 4 ++-- app/controllers/pull_requests_controller.rb | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index ee0b5efff..ddb0facdf 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -109,7 +109,7 @@ class IssuesController < ApplicationController def create issue_params = issue_send_params(params) - Issues::CreateForm.new({subject: issue_params[:subject], description: issue_params[:description].b}).validate! + Issues::CreateForm.new({subject: issue_params[:subject], description: issue_params[:description].blank? ? issue_params[:description] : issue_params[:description].b}).validate! @issue = Issue.new(issue_params) if @issue.save! SendTemplateMessageJob.perform_later('IssueAssigned', current_user.id, @issue&.id) if Site.has_notice_menu? @@ -223,7 +223,7 @@ class IssuesController < ApplicationController normal_status(-1, "不允许修改为关闭状态") else issue_params = issue_send_params(params).except(:issue_classify, :author_id, :project_id) - Issues::UpdateForm.new({subject: issue_params[:subject], description: issue_params[:description].b}).validate! + Issues::UpdateForm.new({subject: issue_params[:subject], description: issue_params[:description].blank? ? issue_params[:description] : issue_params[:description].b}).validate! if @issue.update_attributes(issue_params) if @issue&.pull_request.present? SendTemplateMessageJob.perform_later('PullRequestChanged', current_user.id, @issue&.pull_request&.id, @issue.previous_changes.slice(:assigned_to_id, :priority_id, :fixed_version_id, :issue_tags_value)) if Site.has_notice_menu? diff --git a/app/controllers/journals_controller.rb b/app/controllers/journals_controller.rb index 7c0676590..6dc1e29c9 100644 --- a/app/controllers/journals_controller.rb +++ b/app/controllers/journals_controller.rb @@ -23,7 +23,7 @@ class JournalsController < ApplicationController normal_status(-1, "评论内容不能为空") else ActiveRecord::Base.transaction do - Journals::CreateForm.new({notes: notes.to_s.strip.b}).validate! + Journals::CreateForm.new({notes: notes.to_s.strip.blank? ? notes.to_s.strip : notes.to_s.strip.b}).validate! journal_params = { journalized_id: @issue.id , journalized_type: "Issue", @@ -75,7 +75,7 @@ class JournalsController < ApplicationController def update content = params[:content] if content.present? - Journals::UpdateForm.new({notes: notes.to_s.strip.b}).validate! + Journals::UpdateForm.new({notes: notes.to_s.strip.blank? ? notes.to_s.strip : notes.to_s.strip.b}).validate! if @journal.update_attribute(:notes, content) normal_status(0, "更新成功") else diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index bf5646a4e..f45d1f359 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -58,7 +58,7 @@ class PullRequestsController < ApplicationController def create # return normal_status(-1, "您不是目标分支开发者,没有权限,请联系目标分支作者.") unless @project.operator?(current_user) ActiveRecord::Base.transaction do - Issues::CreateForm.new({subject: params[:title], description: params[:body].b}).validate! + Issues::CreateForm.new({subject: params[:title], description: params[:body].blank? ? params[:body] : params[:body].b}).validate! @pull_request, @gitea_pull_request = PullRequests::CreateService.call(current_user, @owner, @project, params) if @gitea_pull_request[:status] == :success @pull_request.bind_gitea_pull_request!(@gitea_pull_request[:body]["number"], @gitea_pull_request[:body]["id"]) @@ -90,7 +90,7 @@ class PullRequestsController < ApplicationController else ActiveRecord::Base.transaction do begin - Issues::UpdateForm.new({subject: params[:title], description: params[:body].b}).validate! + Issues::UpdateForm.new({subject: params[:title], description: params[:body].blank? ? params[:body] : params[:body].b}).validate! merge_params @issue&.issue_tags_relates&.destroy_all if params[:issue_tag_ids].blank?