Better error handling for changing issue status

This commit is contained in:
Alexander Meindl 2018-02-19 09:11:25 +01:00
parent 1119ad8109
commit 40e6067ed7
9 changed files with 35 additions and 4 deletions

View File

@ -12,7 +12,11 @@ class AdditionalsAssignToMeController < ApplicationController
end
@issue.assigned_to = User.current
@issue.save
if !@issue.save || old_user == @issue.assigned_to
flash[:error] = l(:error_issues_could_not_be_assigned_to_me)
return redirect_to(issue_path(@issue))
end
new_journal = @issue.init_journal(User.current)
new_journal.save!
@ -20,9 +24,9 @@ class AdditionalsAssignToMeController < ApplicationController
last_journal = @issue.journals.visible.order('created_on').last
JournalDetail.new(property: 'attr',
prop_key: 'user',
prop_key: 'assigned_to',
old_value: old_user,
value: User.current.name,
value: @issue.assigned_to,
journal: new_journal).save!
if last_journal.nil?

View File

@ -4,6 +4,7 @@ class AdditionalsChangeStatusController < ApplicationController
def update
issue_old_status = @issue.status.name
issue_old_user = @issue.assigned_to
new_status_id = params[:new_status_id].to_i
allowed_status = @issue.new_statuses_allowed_to(User.current)
.detect { |s| s.id == new_status_id }
@ -14,7 +15,11 @@ class AdditionalsChangeStatusController < ApplicationController
end
@issue.status_id = new_status_id
@issue.save
if !@issue.save || issue_old_status == @issue.status.name
flash[:error] = l(:error_issue_status_could_not_changed)
return redirect_to(issue_path(@issue))
end
new_journal = @issue.init_journal(User.current)
new_journal.save!
@ -27,6 +32,14 @@ class AdditionalsChangeStatusController < ApplicationController
value: @issue.status.name,
journal: new_journal).save!
if @issue.assigned_to != issue_old_user
JournalDetail.new(property: 'attr',
prop_key: 'assigned_to',
old_value: issue_old_user,
value: @issue.assigned_to,
journal: new_journal).save!
end
if last_journal.nil?
redirect_to(issue_path(@issue))
return

View File

@ -156,3 +156,5 @@ de:
wiki_pdf_header_info: Dieser Textblock wir auf der ersten Seite vor dem eigentlichen Inhalt der Wiki Seite in der PDF Ansicht angezeigt. Die Makros sind hier nur eingeschränkt einsetzbar.
wiki_pdf_remove_attachments_info: Wenn aktiv, werden die an der Wiki Seite angehängten Dateien nicht in der PDF Ansicht angezeigt.
wiki_pdf_remove_title_info: Wenn aktiv, wird der Wiki Titel nicht in der PDF Ansicht angezeigt.
error_issues_could_not_be_assigned_to_me: Das Ticket konnte nicht mir zugeordnet werden
error_issue_status_could_not_changed: Der Ticket-Status konnte nicht geändert werden

View File

@ -156,3 +156,5 @@ en:
wiki_pdf_header_info: This text block will be displayed on the first page before the regular Wiki content in the PDF view. Macro use is very restricted, here.
wiki_pdf_remove_attachments_info: When active the attached Wiki files will not be displayed in PDF view.
wiki_pdf_remove_title_info: When active the Wiki title info will not be displayed in PDF view.
error_issues_could_not_be_assigned_to_me: Issue could not assigned to me
error_issue_status_could_not_changed: Issue state could not be changed

View File

@ -156,3 +156,5 @@ fr:
wiki_pdf_header_info: This text block will be displayed on the first page before the regular Wiki content in the PDF view. Macro use is very restricted, here.
wiki_pdf_remove_attachments_info: When active the attached Wiki files will not be displayed in PDF view.
wiki_pdf_remove_title_info: When active the Wiki title info will not be displayed in PDF view.
error_issues_could_not_be_assigned_to_me: Issue could not assigned to me
error_issue_status_could_not_changed: Issue state could not be changed

View File

@ -156,3 +156,5 @@ it:
wiki_pdf_header_info: This text block will be displayed on the first page before the regular Wiki content in the PDF view. Macro use is very restricted, here.
wiki_pdf_remove_attachments_info: "Quando è attivo, il Wiki file allegati non verranno visualizzati nella vista PDF."
wiki_pdf_remove_title_info: "Quando è attivo, le informazioni sul titolo del Wiki non verranno visualizzate nella vista PDF."
error_issues_could_not_be_assigned_to_me: Issue could not assigned to me
error_issue_status_could_not_changed: Issue state could not be changed

View File

@ -156,3 +156,5 @@ ja:
wiki_pdf_header_info: This text block will be displayed on the first page before the regular Wiki content in the PDF view. Macro use is very restricted, here.
wiki_pdf_remove_attachments_info: When active the attached Wiki files will not be displayed in PDF view.
wiki_pdf_remove_title_info: When active the Wiki title info will not be displayed in PDF view.
error_issues_could_not_be_assigned_to_me: Issue could not assigned to me
error_issue_status_could_not_changed: Issue state could not be changed

View File

@ -156,3 +156,5 @@
wiki_pdf_header_info: "該訊息將顯示在PDF第一頁頁首。此處macros指令支援有限。"
wiki_pdf_remove_attachments_info: "當啟用時Wiki附件將不會顯示在PDF中。"
wiki_pdf_remove_title_info: "當啟用時Wiki標題訊息不會顯示在PDF中"
error_issues_could_not_be_assigned_to_me: Issue could not assigned to me
error_issue_status_could_not_changed: Issue state could not be changed

View File

@ -156,3 +156,5 @@ zh:
wiki_pdf_header_info: 该文本快将显示在 PDF 视图中的常规 WIKI 内容之前的第一页上。此处宏命令的使用非常有限。
wiki_pdf_remove_attachments_info: 当启用时WIKI 附件将不会显示在PDF视图中。
wiki_pdf_remove_title_info: 当启用时WIKI 标题信息将不会显示在PDF视图中。
error_issues_could_not_be_assigned_to_me: Issue could not assigned to me
error_issue_status_could_not_changed: Issue state could not be changed