Mercurial > hg > soundsoftware-site
comparison app/models/issue_relation.rb @ 511:107d36338b70 live
Merge from branch "cannam"
author | Chris Cannam |
---|---|
date | Thu, 14 Jul 2011 10:43:07 +0100 |
parents | 0c939c159af4 |
children | cbb26bc654de |
comparison
equal
deleted
inserted
replaced
451:a9f6345cb43d | 511:107d36338b70 |
---|---|
45 | 45 |
46 def validate | 46 def validate |
47 if issue_from && issue_to | 47 if issue_from && issue_to |
48 errors.add :issue_to_id, :invalid if issue_from_id == issue_to_id | 48 errors.add :issue_to_id, :invalid if issue_from_id == issue_to_id |
49 errors.add :issue_to_id, :not_same_project unless issue_from.project_id == issue_to.project_id || Setting.cross_project_issue_relations? | 49 errors.add :issue_to_id, :not_same_project unless issue_from.project_id == issue_to.project_id || Setting.cross_project_issue_relations? |
50 errors.add_to_base :circular_dependency if issue_to.all_dependent_issues.include? issue_from | 50 #detect circular dependencies depending wether the relation should be reversed |
51 if TYPES.has_key?(relation_type) && TYPES[relation_type][:reverse] | |
52 errors.add_to_base :circular_dependency if issue_from.all_dependent_issues.include? issue_to | |
53 else | |
54 errors.add_to_base :circular_dependency if issue_to.all_dependent_issues.include? issue_from | |
55 end | |
51 errors.add_to_base :cant_link_an_issue_with_a_descendant if issue_from.is_descendant_of?(issue_to) || issue_from.is_ancestor_of?(issue_to) | 56 errors.add_to_base :cant_link_an_issue_with_a_descendant if issue_from.is_descendant_of?(issue_to) || issue_from.is_ancestor_of?(issue_to) |
52 end | 57 end |
53 end | 58 end |
54 | 59 |
55 def other_issue(issue) | 60 def other_issue(issue) |
82 set_issue_to_dates | 87 set_issue_to_dates |
83 end | 88 end |
84 | 89 |
85 def set_issue_to_dates | 90 def set_issue_to_dates |
86 soonest_start = self.successor_soonest_start | 91 soonest_start = self.successor_soonest_start |
87 if soonest_start | 92 if soonest_start && issue_to |
88 issue_to.reschedule_after(soonest_start) | 93 issue_to.reschedule_after(soonest_start) |
89 end | 94 end |
90 end | 95 end |
91 | 96 |
92 def successor_soonest_start | 97 def successor_soonest_start |
93 return nil unless (TYPE_PRECEDES == self.relation_type) && (issue_from.start_date || issue_from.due_date) | 98 if (TYPE_PRECEDES == self.relation_type) && delay && issue_from && (issue_from.start_date || issue_from.due_date) |
94 (issue_from.due_date || issue_from.start_date) + 1 + delay | 99 (issue_from.due_date || issue_from.start_date) + 1 + delay |
100 end | |
95 end | 101 end |
96 | 102 |
97 def <=>(relation) | 103 def <=>(relation) |
98 TYPES[self.relation_type][:order] <=> TYPES[relation.relation_type][:order] | 104 TYPES[self.relation_type][:order] <=> TYPES[relation.relation_type][:order] |
99 end | 105 end |