diff --git a/tracks/app/controllers/application.rb b/tracks/app/controllers/application.rb index 6ddab9c3..5fd627c2 100644 --- a/tracks/app/controllers/application.rb +++ b/tracks/app/controllers/application.rb @@ -11,22 +11,23 @@ class ApplicationController < ActionController::Base include LoginSystem # Contstants from settings.yml - DATE_FORMAT = app_configurations["formats"]["date"] + DATE_FORMAT = app_configurations["formats"]["date"] WEEK_STARTS_ON = app_configurations["formats"]["week_starts"] - NO_OF_ACTIONS = app_configurations["formats"]["hp_completed"] + NO_OF_ACTIONS = app_configurations["formats"]["hp_completed"] + STALENESS_STARTS = app_configurations["formats"]["staleness_starts"] def count_shown_items(hidden) - count = 0 - sub = 0 - hidden.each do |h| - sub = Todo.find_all("done=0 AND context_id=#{h.id}").length + sub - end - total = Todo.find_all("done=0").length - sub + count = 0 + sub = 0 + hidden.each do |h| + sub = Todo.find_all("done=0 AND context_id=#{h.id}").length + sub + end + total = Todo.find_all("done=0").length - sub end # Returns all the errors on the page for an object... def errors_for( obj ) - error_messages_for( obj ) unless instance_eval("@#{obj}").nil? + error_messages_for( obj ) unless instance_eval("@#{obj}").nil? end end \ No newline at end of file diff --git a/tracks/app/helpers/application_helper.rb b/tracks/app/helpers/application_helper.rb index 7b55b6c3..a3d679d2 100644 --- a/tracks/app/helpers/application_helper.rb +++ b/tracks/app/helpers/application_helper.rb @@ -55,5 +55,24 @@ module ApplicationHelper "" + format_date(due) + " " end end + + # Uses the 'staleness_starts' value from settings.yml (in days) to colour + # the background of the action appropriately according to the age + # of the creation date: + # * l1: created more than 1 x staleness_starts, but < 2 x staleness_starts + # * l2: created more than 2 x staleness_starts, but < 3 x staleness_starts + # * l3: created more than 3 x staleness_starts + # + def staleness(created) + if created < (ApplicationController::STALENESS_STARTS*3).days.ago + return "