diff options
author | Eric Davis <edavis@littlestreamsoftware.com> | 2010-09-14 19:02:25 +0000 |
---|---|---|
committer | Eric Davis <edavis@littlestreamsoftware.com> | 2010-09-14 19:02:25 +0000 |
commit | cdfc57d5442f72d62437f52af480049c943ecbf8 (patch) | |
tree | 576cbf92e5bdeec589544476cc83de216adda120 /app/models/time_entry.rb | |
parent | 8900797adaf29adc447925b800d5457ca941795f (diff) | |
download | redmine-cdfc57d5442f72d62437f52af480049c943ecbf8.tar.gz redmine-cdfc57d5442f72d62437f52af480049c943ecbf8.zip |
Change the TimelogController's to/from dates based on the project time entries
Instead of looking for the earliest and latest time entry system wide for the
dates in the form, now TimelogController will only look at the time entries
for the current project (and parent/sub projects).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4087 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/time_entry.rb')
-rw-r--r-- | app/models/time_entry.rb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb index 56801a4ca..9bf970891 100644 --- a/app/models/time_entry.rb +++ b/app/models/time_entry.rb @@ -82,11 +82,19 @@ class TimeEntry < ActiveRecord::Base end end - def self.earilest_date_for_project - TimeEntry.minimum(:spent_on, :include => :project, :conditions => Project.allowed_to_condition(User.current, :view_time_entries)) + def self.earilest_date_for_project(project=nil) + finder_conditions = ARCondition.new(Project.allowed_to_condition(User.current, :view_time_entries)) + if project + finder_conditions << ["project_id IN (?)", project.hierarchy.collect(&:id)] + end + TimeEntry.minimum(:spent_on, :include => :project, :conditions => finder_conditions.conditions) end - def self.latest_date_for_project - TimeEntry.maximum(:spent_on, :include => :project, :conditions => Project.allowed_to_condition(User.current, :view_time_entries)) + def self.latest_date_for_project(project=nil) + finder_conditions = ARCondition.new(Project.allowed_to_condition(User.current, :view_time_entries)) + if project + finder_conditions << ["project_id IN (?)", project.hierarchy.collect(&:id)] + end + TimeEntry.maximum(:spent_on, :include => :project, :conditions => finder_conditions.conditions) end end |