diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/timelog_controller.rb | 4 | ||||
-rw-r--r-- | app/models/time_entry.rb | 8 |
2 files changed, 10 insertions, 2 deletions
diff --git a/app/controllers/timelog_controller.rb b/app/controllers/timelog_controller.rb index e234848d0..726c69d5b 100644 --- a/app/controllers/timelog_controller.rb +++ b/app/controllers/timelog_controller.rb @@ -260,8 +260,8 @@ private end @from, @to = @to, @from if @from && @to && @from > @to - @from ||= (TimeEntry.minimum(:spent_on, :include => :project, :conditions => Project.allowed_to_condition(User.current, :view_time_entries)) || Date.today) - 1 - @to ||= (TimeEntry.maximum(:spent_on, :include => :project, :conditions => Project.allowed_to_condition(User.current, :view_time_entries)) || Date.today) + @from ||= (TimeEntry.earilest_date_for_project || Date.today) - 1 + @to ||= (TimeEntry.latest_date_for_project || Date.today) end def load_available_criterias diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb index 73f39f949..56801a4ca 100644 --- a/app/models/time_entry.rb +++ b/app/models/time_entry.rb @@ -81,4 +81,12 @@ class TimeEntry < ActiveRecord::Base yield end end + + def self.earilest_date_for_project + TimeEntry.minimum(:spent_on, :include => :project, :conditions => Project.allowed_to_condition(User.current, :view_time_entries)) + end + + def self.latest_date_for_project + TimeEntry.maximum(:spent_on, :include => :project, :conditions => Project.allowed_to_condition(User.current, :view_time_entries)) + end end |