Patches against version 0.1.6 » redmine_issues_group-journal.patch
| redmine_issues_group/init.rb 2009-11-05 22:07:28.000000000 -0500 | ||
|---|---|---|
| 27 | 27 | Dispatcher.to_prepare do | 
| 28 | 28 | IssuesHelper.send(:include, IssuesHelperPatch) | 
| 29 | 29 | Issue.send(:include, IssueRelationPatch) | 
| 30 | Issue.send(:include, IssueJournalPatch) | |
| 30 | 31 | CollectiveIdea::Acts::NestedSet::InstanceMethods.send(:include, AwesomeNestedSetIssuesPatch) | 
| 31 | 32 | end | 
| redmine_issues_group/lib/issue_journal_patch.rb 2009-11-05 22:09:29.000000000 -0500 | ||
|---|---|---|
| 1 | ||
| 2 | require 'issue' | |
| 3 | ||
| 4 | module IssueJournalPatch | |
| 5 | def self.included(base) # :nodoc: | |
| 6 | base.class_eval do | |
| 7 | ||
| 8 | # Saves the changes in a Journal | |
| 9 | # Called after_save | |
| 10 | def create_journal | |
| 11 | if @current_journal | |
| 12 | # attributes changes | |
| 13 |           (Issue.column_names - %w(id description lock_version created_on updated_on)).each {|c| | |
| 14 | @current_journal.details << JournalDetail.new(:property => 'attr', | |
| 15 | :prop_key => c, | |
| 16 | :old_value => @issue_before_change.send(c), | |
| 17 | :value => send(c)) unless send(c)==@issue_before_change.send(c) || | |
| 18 | @current_journal.details.exists?(:property => 'attr', | |
| 19 | :prop_key => c, | |
| 20 | :old_value => @issue_before_change.send(c), | |
| 21 | :value => send(c)) | |
| 22 | } | |
| 23 | # custom fields changes | |
| 24 |           custom_values.each {|c| | |
| 25 | next if (@custom_values_before_change[c.custom_field_id]==c.value || | |
| 26 | (@custom_values_before_change[c.custom_field_id].blank? && c.value.blank?)) || | |
| 27 | @current_journal.details.exists?(:property => 'cf', | |
| 28 | :prop_key => c.custom_field_id, | |
| 29 | :old_value => @custom_values_before_change[c.custom_field_id], | |
| 30 | :value => c.value) | |
| 31 | @current_journal.details << JournalDetail.new(:property => 'cf', | |
| 32 | :prop_key => c.custom_field_id, | |
| 33 | :old_value => @custom_values_before_change[c.custom_field_id], | |
| 34 | :value => c.value) | |
| 35 | } | |
| 36 | @current_journal.save | |
| 37 | end | |
| 38 | end | |
| 39 | ||
| 40 | end | |
| 41 | end | |
| 42 | end | |