diff app/models/time_entry.rb @ 909:cbb26bc654de redmine-1.3

Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author Chris Cannam
date Fri, 24 Feb 2012 19:09:32 +0000
parents cbce1fd3b1b7
children 5f33065ddc4b
line wrap: on
line diff
--- a/app/models/time_entry.rb	Fri Feb 24 18:36:29 2012 +0000
+++ b/app/models/time_entry.rb	Fri Feb 24 19:09:32 2012 +0000
@@ -38,6 +38,8 @@
   validates_presence_of :user_id, :activity_id, :project_id, :hours, :spent_on
   validates_numericality_of :hours, :allow_nil => true, :message => :invalid
   validates_length_of :comments, :maximum => 255, :allow_nil => true
+  before_validation :set_project_if_nil
+  validate :validate_time_entry
 
   named_scope :visible, lambda {|*args| {
     :include => :project,
@@ -53,11 +55,11 @@
     end
   end
 
-  def before_validation
+  def set_project_if_nil
     self.project = issue.project if issue && project.nil?
   end
 
-  def validate
+  def validate_time_entry
     errors.add :hours, :invalid if hours && (hours < 0 || hours >= 1000)
     errors.add :project_id, :invalid if project.nil?
     errors.add :issue_id, :invalid if (issue_id && !issue) || (issue && project!=issue.project)
@@ -84,14 +86,6 @@
     (usr == user && usr.allowed_to?(:edit_own_time_entries, project)) || usr.allowed_to?(:edit_time_entries, project)
   end
 
-  # TODO: remove this method in 1.3.0
-  def self.visible_by(usr)
-    ActiveSupport::Deprecation.warn "TimeEntry.visible_by is deprecated and will be removed in Redmine 1.3.0. Use the visible scope instead."
-    with_scope(:find => { :conditions => Project.allowed_to_condition(usr, :view_time_entries) }) do
-      yield
-    end
-  end
-
   def self.earilest_date_for_project(project=nil)
     finder_conditions = ARCondition.new(Project.allowed_to_condition(User.current, :view_time_entries))
     if project