summaryrefslogtreecommitdiffstats
path: root/app/models/issue_relation.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/issue_relation.rb')
-rw-r--r--app/models/issue_relation.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/app/models/issue_relation.rb b/app/models/issue_relation.rb
index 9e5015644..1de565011 100644
--- a/app/models/issue_relation.rb
+++ b/app/models/issue_relation.rb
@@ -72,6 +72,8 @@ class IssueRelation < ActiveRecord::Base
attr_protected :issue_from_id, :issue_to_id
before_save :handle_issue_order
+ after_create :create_journal_after_create
+ after_destroy :create_journal_after_delete
def visible?(user=User.current)
(issue_from.nil? || issue_from.visible?(user)) && (issue_to.nil? || issue_to.visible?(user))
@@ -179,4 +181,30 @@ class IssueRelation < ActiveRecord::Base
self.relation_type = TYPES[relation_type][:reverse]
end
end
+
+ def create_journal_after_create
+ journal = issue_from.init_journal(User.current)
+ journal.details << JournalDetail.new(:property => 'relation',
+ :prop_key => label_for(issue_from).to_s,
+ :value => issue_to.id)
+ journal.save
+ journal = issue_to.init_journal(User.current)
+ journal.details << JournalDetail.new(:property => 'relation',
+ :prop_key => label_for(issue_to).to_s,
+ :value => issue_from.id)
+ journal.save
+ end
+
+ def create_journal_after_delete
+ journal = issue_from.init_journal(User.current)
+ journal.details << JournalDetail.new(:property => 'relation',
+ :prop_key => label_for(issue_from).to_s,
+ :old_value => issue_to.id)
+ journal.save
+ journal = issue_to.init_journal(User.current)
+ journal.details << JournalDetail.new(:property => 'relation',
+ :prop_key => label_for(issue_to).to_s,
+ :old_value => issue_from.id)
+ journal.save
+ end
end