model: replace Rails2 "named_scope" to Rails3 "scope"

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9537 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA
2012-04-26 23:51:10 +00:00
parent 71649ba2f1
commit d0d01d4e70
19 changed files with 49 additions and 47 deletions
+4 -4
View File
@@ -42,19 +42,19 @@ class TimeEntry < ActiveRecord::Base
before_validation :set_project_if_nil
validate :validate_time_entry
named_scope :visible, lambda {|*args| {
scope :visible, lambda {|*args| {
:include => :project,
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_time_entries, *args)
}}
named_scope :on_issue, lambda {|issue| {
scope :on_issue, lambda {|issue| {
:include => :issue,
:conditions => "#{Issue.table_name}.root_id = #{issue.root_id} AND #{Issue.table_name}.lft >= #{issue.lft} AND #{Issue.table_name}.rgt <= #{issue.rgt}"
}}
named_scope :on_project, lambda {|project, include_subprojects| {
scope :on_project, lambda {|project, include_subprojects| {
:include => :project,
:conditions => project.project_condition(include_subprojects)
}}
named_scope :spent_between, lambda {|from, to|
scope :spent_between, lambda {|from, to|
if from && to
{:conditions => ["#{TimeEntry.table_name}.spent_on BETWEEN ? AND ?", from, to]}
elsif from