Project

General

Profile

Patch #777 ยป move_versiondate_2issuedate.txt

Charles-Marie DE GRAEVE, 2008-03-03 16:44

 
1
diff -Naur trunk_6.3/app/models/issue.rb eads_ver/app/models/issue.rb
2
--- trunk_6.3/app/models/issue.rb	2007-12-18 19:17:40.000000000 +0100
3
+++ eads_ver/app/models/issue.rb	2008-02-29 17:28:48.000000000 +0100
4
@@ -117,7 +117,10 @@
5
     end
6
   end
7
   
8
-  def before_save  
9
+  def before_save
10
+  
11
+  self.due_date = self.fixed_version.effective_date unless self.fixed_version.nil?
12
+     
13
     if @current_journal
14
       # attributes changes
15
       (Issue.column_names - %w(id description)).each {|c|
16
@@ -143,8 +146,13 @@
17
   
18
   def after_save
19
     # Update start/due dates of following issues
20
-    relations_from.each(&:set_issue_to_dates)
21
-    
22
+    #relations_from.each(&:set_issue_to_dates)
23
+    
24
+    IssueRelation.find(:all, :conditions => { :issue_to_id => self.id }).collect do |i|
25
+                i.issue_from.due_date = self.due_date
26
+                i.issue_from.save
27
+    end
28
+        
29
     # Close duplicates if the issue was closed
30
     if @issue_before_change && !@issue_before_change.closed? && self.closed?
31
       duplicates.each do |duplicate|
32
diff -Naur trunk_6.3/app/models/version.rb eads_ver/app/models/version.rb
33
--- trunk_6.3/app/models/version.rb	2007-12-18 19:17:40.000000000 +0100
34
+++ eads_ver/app/models/version.rb	2008-02-29 16:47:43.000000000 +0100
35
@@ -15,7 +15,8 @@
36
 # along with this program; if not, write to the Free Software
37
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
38
 
39
-class Version < ActiveRecord::Base
40
+class Version < ActiveRecord::Base
41
+
42
   before_destroy :check_integrity
43
   belongs_to :project
44
   has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id'
45
@@ -25,6 +26,13 @@
46
   validates_uniqueness_of :name, :scope => [:project_id]
47
   validates_length_of :name, :maximum => 30
48
   validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => :activerecord_error_not_a_date, :allow_nil => true
49
+  
50
+  def after_save
51
+    Issue.find(:all, :conditions => {:fixed_version_id => self.id }).collect do |i|
52
+        i.due_date = self.effective_date
53
+        i.save
54
+    end
55
+  end
56
   
57
   def start_date
58
     effective_date
59

    
    (1-1/1)