diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index dfa485a70..8390fc61c 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -227,7 +227,7 @@ module IssuesHelper strings = [] values_by_field = {} details.each do |detail| - unless detail.property == 'attachment' + if detail.property == 'cf' field_id = detail.prop_key field = CustomField.find_by_id(field_id) @@ -243,7 +243,7 @@ module IssuesHelper end end strings << show_detail(detail, no_html, options) - end + end values_by_field.each do |field_id, changes| detail = JournalDetail.new(:property => 'cf', :prop_key => field_id) diff --git a/app/models/issue.rb b/app/models/issue.rb index 09e093177..4dc685b3b 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -51,7 +51,7 @@ class Issue < ActiveRecord::Base acts_as_nested_set :scope => 'root_id', :dependent => :destroy - acts_as_attachable :after_add => :attachment_added, :after_remove => :attachment_removed + acts_as_attachable :before_add => :attachment_added, :after_remove => :attachment_removed acts_as_customizable acts_as_watchable acts_as_searchable :columns => ['subject', "#{table_name}.description", "#{Journal.table_name}.notes"], @@ -1359,7 +1359,7 @@ class Issue < ActiveRecord::Base # Callback on file attachment def attachment_added(obj) - if @current_journal && !obj.new_record? && @current_journal.journalized_id == obj.author_id + if @current_journal && @current_journal.user_id == obj.author_id && JournalDetail.find_all_by_value(obj.filename).count == 0 @current_journal.details << JournalDetail.new(:property => 'attachment', :prop_key => obj.id, :value => obj.filename) end end