Better handling of issue update conflicts (#8691).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8774 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -171,7 +171,7 @@ class IssuesController < ApplicationController
|
||||
end
|
||||
|
||||
def edit
|
||||
update_issue_from_params
|
||||
return unless update_issue_from_params
|
||||
|
||||
respond_to do |format|
|
||||
format.html { }
|
||||
@@ -180,9 +180,23 @@ class IssuesController < ApplicationController
|
||||
end
|
||||
|
||||
def update
|
||||
update_issue_from_params
|
||||
return unless update_issue_from_params
|
||||
saved = false
|
||||
begin
|
||||
saved = @issue.save_issue_with_child_records(params, @time_entry)
|
||||
rescue ActiveRecord::StaleObjectError
|
||||
@conflict = true
|
||||
if params[:last_journal_id]
|
||||
if params[:last_journal_id].present?
|
||||
last_journal_id = params[:last_journal_id].to_i
|
||||
@conflict_journals = @issue.journals.all(:conditions => ["#{Journal.table_name}.id > ?", last_journal_id])
|
||||
else
|
||||
@conflict_journals = @issue.journals.all
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if @issue.save_issue_with_child_records(params, @time_entry)
|
||||
if saved
|
||||
render_attachment_warning_if_needed(@issue)
|
||||
flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record?
|
||||
|
||||
@@ -345,7 +359,22 @@ private
|
||||
|
||||
@notes = params[:notes] || (params[:issue].present? ? params[:issue][:notes] : nil)
|
||||
@issue.init_journal(User.current, @notes)
|
||||
@issue.safe_attributes = params[:issue]
|
||||
|
||||
issue_attributes = params[:issue]
|
||||
if issue_attributes && params[:conflict_resolution]
|
||||
case params[:conflict_resolution]
|
||||
when 'overwrite'
|
||||
issue_attributes = issue_attributes.dup
|
||||
issue_attributes.delete(:lock_version)
|
||||
when 'add_notes'
|
||||
issue_attributes = {}
|
||||
when 'cancel'
|
||||
redirect_to issue_path(@issue)
|
||||
return false
|
||||
end
|
||||
end
|
||||
@issue.safe_attributes = issue_attributes
|
||||
true
|
||||
end
|
||||
|
||||
# TODO: Refactor, lots of extra code in here
|
||||
|
||||
Reference in New Issue
Block a user