add: issues description and journals notes validate
This commit is contained in:
parent
7c88ea3d67
commit
ae7d0d1329
|
@ -109,7 +109,7 @@ class IssuesController < ApplicationController
|
||||||
|
|
||||||
def create
|
def create
|
||||||
issue_params = issue_send_params(params)
|
issue_params = issue_send_params(params)
|
||||||
Issues::CreateForm.new({subject:issue_params[:subject]}).validate!
|
Issues::CreateForm.new(issue_params.slice(:subject, :description)).validate!
|
||||||
@issue = Issue.new(issue_params)
|
@issue = Issue.new(issue_params)
|
||||||
if @issue.save!
|
if @issue.save!
|
||||||
SendTemplateMessageJob.perform_later('IssueAssigned', current_user.id, @issue&.id) if Site.has_notice_menu?
|
SendTemplateMessageJob.perform_later('IssueAssigned', current_user.id, @issue&.id) if Site.has_notice_menu?
|
||||||
|
@ -223,7 +223,7 @@ class IssuesController < ApplicationController
|
||||||
normal_status(-1, "不允许修改为关闭状态")
|
normal_status(-1, "不允许修改为关闭状态")
|
||||||
else
|
else
|
||||||
issue_params = issue_send_params(params).except(:issue_classify, :author_id, :project_id)
|
issue_params = issue_send_params(params).except(:issue_classify, :author_id, :project_id)
|
||||||
Issues::UpdateForm.new({subject:issue_params[:subject]}).validate!
|
Issues::UpdateForm.new(issue_params.slice(:subject, :description)).validate!
|
||||||
if @issue.update_attributes(issue_params)
|
if @issue.update_attributes(issue_params)
|
||||||
if @issue&.pull_request.present?
|
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?
|
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?
|
||||||
|
|
|
@ -23,6 +23,7 @@ class JournalsController < ApplicationController
|
||||||
normal_status(-1, "评论内容不能为空")
|
normal_status(-1, "评论内容不能为空")
|
||||||
else
|
else
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
|
Journals::CreateForm.new({notes: notes.to_s.strip}).validate!
|
||||||
journal_params = {
|
journal_params = {
|
||||||
journalized_id: @issue.id ,
|
journalized_id: @issue.id ,
|
||||||
journalized_type: "Issue",
|
journalized_type: "Issue",
|
||||||
|
@ -53,6 +54,9 @@ class JournalsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
rescue Exception => exception
|
||||||
|
puts exception.message
|
||||||
|
normal_status(-1, exception.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
@ -71,6 +75,7 @@ class JournalsController < ApplicationController
|
||||||
def update
|
def update
|
||||||
content = params[:content]
|
content = params[:content]
|
||||||
if content.present?
|
if content.present?
|
||||||
|
Journals::UpdateForm.new({notes: notes.to_s.strip}).validate!
|
||||||
if @journal.update_attribute(:notes, content)
|
if @journal.update_attribute(:notes, content)
|
||||||
normal_status(0, "更新成功")
|
normal_status(0, "更新成功")
|
||||||
else
|
else
|
||||||
|
@ -79,7 +84,9 @@ class JournalsController < ApplicationController
|
||||||
else
|
else
|
||||||
normal_status(-1, "评论的内容不能为空")
|
normal_status(-1, "评论的内容不能为空")
|
||||||
end
|
end
|
||||||
|
rescue Exception => exception
|
||||||
|
puts exception.message
|
||||||
|
normal_status(-1, exception.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_children_journals
|
def get_children_journals
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
class Issues::CreateForm
|
class Issues::CreateForm
|
||||||
include ActiveModel::Model
|
include ActiveModel::Model
|
||||||
|
|
||||||
attr_accessor :subject
|
attr_accessor :subject, :description
|
||||||
|
|
||||||
validates :subject, presence: { message: "不能为空" }
|
validates :subject, presence: { message: "不能为空" }
|
||||||
|
|
||||||
validates :subject, length: { maximum: 200, too_long: "不能超过200个字符" }
|
validates :subject, length: { maximum: 200, too_long: "不能超过200个字符" }
|
||||||
|
|
||||||
|
validates :description, length: { maximum: 65535, too_long: "不能超过65535个字符"}
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
class Issues::UpdateForm
|
class Issues::UpdateForm
|
||||||
include ActiveModel::Model
|
include ActiveModel::Model
|
||||||
|
|
||||||
attr_accessor :subject
|
attr_accessor :subject, :description
|
||||||
|
|
||||||
validates :subject, presence: { message: "不能为空" }
|
validates :subject, presence: { message: "不能为空" }
|
||||||
|
|
||||||
validates :subject, length: { maximum: 200, too_long: "不能超过200个字符" }
|
validates :subject, length: { maximum: 200, too_long: "不能超过200个字符" }
|
||||||
|
|
||||||
|
validates :description, length: { maximum: 65535, too_long: "不能超过65535个字符"}
|
||||||
|
|
||||||
end
|
end
|
|
@ -0,0 +1,7 @@
|
||||||
|
class Journals::CreateForm
|
||||||
|
include ActiveModel::Model
|
||||||
|
|
||||||
|
attr_accessor :notes
|
||||||
|
|
||||||
|
validates :notes, length: { maximum: 65535, too_long: "不能超过65535个字符"}
|
||||||
|
end
|
|
@ -0,0 +1,8 @@
|
||||||
|
class Journals::UpdateForm
|
||||||
|
include ActiveModel::Model
|
||||||
|
|
||||||
|
attr_accessor :notes
|
||||||
|
|
||||||
|
validates :notes, length: { maximum: 65535, too_long: "不能超过65535个字符"}
|
||||||
|
|
||||||
|
end
|
|
@ -3,5 +3,11 @@
|
||||||
attributes:
|
attributes:
|
||||||
issues/create_form:
|
issues/create_form:
|
||||||
subject: 标题
|
subject: 标题
|
||||||
|
description: 描述
|
||||||
issues/update_form:
|
issues/update_form:
|
||||||
subject: 标题
|
subject: 标题
|
||||||
|
description: 描述
|
||||||
|
journals/create_form:
|
||||||
|
notes: 评论
|
||||||
|
journals/update_form:
|
||||||
|
notes: 评论
|
Loading…
Reference in New Issue