summaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2010-05-01 14:07:36 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2010-05-01 14:07:36 +0000
commitcbd4af236cd34b54f250dfbdd94f3176582b7b6c (patch)
tree4d87cafd649be9fb72e35a6554aa628391eb207a /app/models
parenta499efd3288ab742a5f809a6bc87b4a7d48cf50a (diff)
downloadredmine-cbd4af236cd34b54f250dfbdd94f3176582b7b6c.tar.gz
redmine-cbd4af236cd34b54f250dfbdd94f3176582b7b6c.zip
Adds issue relations to individual issue XML (#5305).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3729 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r--app/models/issue_relation.rb25
1 files changed, 18 insertions, 7 deletions
diff --git a/app/models/issue_relation.rb b/app/models/issue_relation.rb
index a28175d48..b79592291 100644
--- a/app/models/issue_relation.rb
+++ b/app/models/issue_relation.rb
@@ -27,13 +27,13 @@ class IssueRelation < ActiveRecord::Base
TYPE_PRECEDES = "precedes"
TYPE_FOLLOWS = "follows"
- TYPES = { TYPE_RELATES => { :name => :label_relates_to, :sym_name => :label_relates_to, :order => 1 },
- TYPE_DUPLICATES => { :name => :label_duplicates, :sym_name => :label_duplicated_by, :order => 2 },
- TYPE_DUPLICATED => { :name => :label_duplicated_by, :sym_name => :label_duplicates, :order => 3, :reverse => TYPE_DUPLICATES },
- TYPE_BLOCKS => { :name => :label_blocks, :sym_name => :label_blocked_by, :order => 4 },
- TYPE_BLOCKED => { :name => :label_blocked_by, :sym_name => :label_blocks, :order => 5, :reverse => TYPE_BLOCKS },
- TYPE_PRECEDES => { :name => :label_precedes, :sym_name => :label_follows, :order => 6 },
- TYPE_FOLLOWS => { :name => :label_follows, :sym_name => :label_precedes, :order => 7, :reverse => TYPE_PRECEDES }
+ TYPES = { TYPE_RELATES => { :name => :label_relates_to, :sym_name => :label_relates_to, :order => 1, :sym => TYPE_RELATES },
+ TYPE_DUPLICATES => { :name => :label_duplicates, :sym_name => :label_duplicated_by, :order => 2, :sym => TYPE_DUPLICATED },
+ TYPE_DUPLICATED => { :name => :label_duplicated_by, :sym_name => :label_duplicates, :order => 3, :sym => TYPE_DUPLICATES, :reverse => TYPE_DUPLICATES },
+ TYPE_BLOCKS => { :name => :label_blocks, :sym_name => :label_blocked_by, :order => 4, :sym => TYPE_BLOCKED },
+ TYPE_BLOCKED => { :name => :label_blocked_by, :sym_name => :label_blocks, :order => 5, :sym => TYPE_BLOCKS, :reverse => TYPE_BLOCKS },
+ TYPE_PRECEDES => { :name => :label_precedes, :sym_name => :label_follows, :order => 6, :sym => TYPE_FOLLOWS },
+ TYPE_FOLLOWS => { :name => :label_follows, :sym_name => :label_precedes, :order => 7, :sym => TYPE_PRECEDES, :reverse => TYPE_PRECEDES }
}.freeze
validates_presence_of :issue_from, :issue_to, :relation_type
@@ -56,6 +56,17 @@ class IssueRelation < ActiveRecord::Base
(self.issue_from_id == issue.id) ? issue_to : issue_from
end
+ # Returns the relation type for +issue+
+ def relation_type_for(issue)
+ if TYPES[relation_type]
+ if self.issue_from_id == issue.id
+ relation_type
+ else
+ TYPES[relation_type][:sym]
+ end
+ end
+ end
+
def label_for(issue)
TYPES[relation_type] ? TYPES[relation_type][(self.issue_from_id == issue.id) ? :name : :sym_name] : :unknow
end