Record time of closure of a bug.
authorKai Krueger <kakrueger@gmail.com>
Wed, 10 Mar 2010 08:42:07 +0000 (08:42 +0000)
committerKai Krueger <kakrueger@gmail.com>
Wed, 10 Mar 2010 08:42:07 +0000 (08:42 +0000)
app/models/map_bug.rb
db/migrate/053_add_date_closed.rb [new file with mode: 0644]

index e04e180be2a7b40bac4d5033a86525481b107f69..18e6ab2707efbf72e68984a8fe950c6cc4fa5f96 100644 (file)
@@ -9,6 +9,7 @@ class MapBug < ActiveRecord::Base
   validates_numericality_of :longitude, :only_integer => true
   validates_presence_of :date_created
   validates_presence_of :last_changed
   validates_numericality_of :longitude, :only_integer => true
   validates_presence_of :date_created
   validates_presence_of :last_changed
+  validates_prensence_of :date_closed if :status == "closed"
   validates_inclusion_of :status, :in => [ "open", "closed", "hidden" ]
 
   has_many :map_bug_comment, :foreign_key => :bug_id, :order => :date_created, :conditions => { :visible => true } 
   validates_inclusion_of :status, :in => [ "open", "closed", "hidden" ]
 
   has_many :map_bug_comment, :foreign_key => :bug_id, :order => :date_created, :conditions => { :visible => true } 
@@ -25,7 +26,10 @@ class MapBug < ActiveRecord::Base
 
   def close_bug
        self.status = "closed"
 
   def close_bug
        self.status = "closed"
-       self.last_changed = Time.now.getutc
+       close_time = Time.now.getutc
+       self.last_changed = close_time
+       self.date_closed = close_time
+
        self.save;
   end
 
        self.save;
   end
 
diff --git a/db/migrate/053_add_date_closed.rb b/db/migrate/053_add_date_closed.rb
new file mode 100644 (file)
index 0000000..7f609ca
--- /dev/null
@@ -0,0 +1,13 @@
+require 'lib/migrate'
+
+class AddDateClosed < ActiveRecord::Migration
+  def self.up
+
+       add_column :map_bugs, :date_closed, :timestamp
+  end
+
+  def self.down
+
+       remove_column :map_bugs, :date_closed 
+  end
+end