diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-12-04 22:49:46 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-12-04 22:49:46 +0000 |
commit | 9e5ed4208b8dc531f77708e84f6d11eba3f1ca4a (patch) | |
tree | a8a6b0ef7a6593ed41dd0ac919ca44d644eba982 /app/models/time_entry.rb | |
parent | ff0f141126e4f196deebf74e74e6eb16e8e72e5f (diff) | |
download | redmine-9e5ed4208b8dc531f77708e84f6d11eba3f1ca4a.tar.gz redmine-9e5ed4208b8dc531f77708e84f6d11eba3f1ca4a.zip |
Adds named scopes for time entries index.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8084 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/time_entry.rb')
-rw-r--r-- | app/models/time_entry.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb index 1afe54829..f4716d0ac 100644 --- a/app/models/time_entry.rb +++ b/app/models/time_entry.rb @@ -45,7 +45,18 @@ class TimeEntry < ActiveRecord::Base :include => :project, :conditions => Project.allowed_to_condition(args.shift || User.current, :view_time_entries, *args) }} - + named_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| { + :include => :project, + :conditions => project.project_condition(include_subprojects) + }} + named_scope :spent_between, lambda {|from, to| { + :conditions => ["#{TimeEntry.table_name}.spent_on BETWEEN ? AND ?", from, to] + }} + def after_initialize if new_record? && self.activity.nil? if default_activity = TimeEntryActivity.default |