summaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2011-03-16 17:29:30 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2011-03-16 17:29:30 +0000
commit0786b9ef99b0797f06a72201b1581d7384efc624 (patch)
treefd4abfc5b9476450092ff90a378e3f443b7b1505 /app/models
parent7ffdd961e9f92a2f1eb86f1d38ce056e1507e2b3 (diff)
downloadredmine-0786b9ef99b0797f06a72201b1581d7384efc624.tar.gz
redmine-0786b9ef99b0797f06a72201b1581d7384efc624.zip
Replaces TimeEntry.visible_by with a visible scope.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5149 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r--app/models/time_entry.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb
index ade802868..c89ead322 100644
--- a/app/models/time_entry.rb
+++ b/app/models/time_entry.rb
@@ -1,5 +1,5 @@
-# redMine - project management software
-# Copyright (C) 2006-2008 Jean-Philippe Lang
+# Redmine - project management software
+# Copyright (C) 2006-2011 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -38,6 +38,11 @@ class TimeEntry < ActiveRecord::Base
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
+
+ named_scope :visible, lambda {|*args| {
+ :include => :project,
+ :conditions => Project.allowed_to_condition(args.first || User.current, :view_time_entries)
+ }}
def after_initialize
if new_record? && self.activity.nil?
@@ -79,7 +84,9 @@ class TimeEntry < ActiveRecord::Base
(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