Fixed: unable to add a file to an issue without entering a note.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@853 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
ecfc40629f
commit
0e4e0a795a
@ -94,21 +94,19 @@ class IssuesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def add_note
|
def add_note
|
||||||
unless params[:notes].empty?
|
journal = @issue.init_journal(User.current, params[:notes])
|
||||||
journal = @issue.init_journal(self.logged_in_user, params[:notes])
|
params[:attachments].each { |file|
|
||||||
if @issue.save
|
next unless file.size > 0
|
||||||
params[:attachments].each { |file|
|
a = Attachment.create(:container => @issue, :file => file, :author => logged_in_user)
|
||||||
next unless file.size > 0
|
journal.details << JournalDetail.new(:property => 'attachment',
|
||||||
a = Attachment.create(:container => @issue, :file => file, :author => logged_in_user)
|
:prop_key => a.id,
|
||||||
journal.details << JournalDetail.new(:property => 'attachment',
|
:value => a.filename) unless a.new_record?
|
||||||
:prop_key => a.id,
|
} if params[:attachments] and params[:attachments].is_a? Array
|
||||||
:value => a.filename) unless a.new_record?
|
if journal.save
|
||||||
} if params[:attachments] and params[:attachments].is_a? Array
|
flash[:notice] = l(:notice_successful_update)
|
||||||
flash[:notice] = l(:notice_successful_update)
|
Mailer.deliver_issue_edit(journal) if Setting.notified_events.include?('issue_updated')
|
||||||
Mailer.deliver_issue_edit(journal) if Setting.notified_events.include?('issue_updated')
|
redirect_to :action => 'show', :id => @issue
|
||||||
redirect_to :action => 'show', :id => @issue
|
return
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
show
|
show
|
||||||
end
|
end
|
||||||
|
@ -98,8 +98,10 @@ class Issue < ActiveRecord::Base
|
|||||||
:old_value => @custom_values_before_change[c.custom_field_id],
|
:old_value => @custom_values_before_change[c.custom_field_id],
|
||||||
:value => c.value)
|
:value => c.value)
|
||||||
}
|
}
|
||||||
@current_journal.save unless @current_journal.details.empty? and @current_journal.notes.empty?
|
@current_journal.save
|
||||||
end
|
end
|
||||||
|
# Save the issue even if the journal is not saved (because empty)
|
||||||
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_save
|
def after_save
|
||||||
|
@ -28,4 +28,9 @@ class Journal < ActiveRecord::Base
|
|||||||
:include => :issue,
|
:include => :issue,
|
||||||
:project_key => "#{Issue.table_name}.project_id",
|
:project_key => "#{Issue.table_name}.project_id",
|
||||||
:date_column => "#{Issue.table_name}.created_on"
|
:date_column => "#{Issue.table_name}.created_on"
|
||||||
|
|
||||||
|
def save
|
||||||
|
# Do not save an empty journal
|
||||||
|
(details.empty? && notes.blank?) ? false : super
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user