Adds a css class (overdue) to overdue issues on issue lists and detail views (#2337).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2140 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2008-12-16 21:13:35 +00:00
parent 02c2a83494
commit 2564f05037
3 changed files with 13 additions and 0 deletions

View File

@ -36,6 +36,7 @@ module IssuesHelper
# Returns a string of css classes that apply to the given issue # Returns a string of css classes that apply to the given issue
def css_issue_classes(issue) def css_issue_classes(issue)
s = "issue status-#{issue.status.position} priority-#{issue.priority.position}" s = "issue status-#{issue.status.position} priority-#{issue.priority.position}"
s << ' overdue' if issue.overdue?
s s
end end

View File

@ -195,6 +195,11 @@ class Issue < ActiveRecord::Base
self.status.is_closed? self.status.is_closed?
end end
# Returns true if the issue is overdue
def overdue?
!due_date.nil? && (due_date < Date.today)
end
# Users the issue can be assigned to # Users the issue can be assigned to
def assignable_users def assignable_users
project.assignable_users project.assignable_users

View File

@ -190,4 +190,11 @@ class IssueTest < Test::Unit::TestCase
assert_nil Issue.find_by_id(1) assert_nil Issue.find_by_id(1)
assert_nil TimeEntry.find_by_issue_id(1) assert_nil TimeEntry.find_by_issue_id(1)
end end
def test_overdue
assert Issue.new(:due_date => 1.day.ago).overdue?
assert !Issue.new(:due_date => Date.today).overdue?
assert !Issue.new(:due_date => 1.day.from_now).overdue?
assert !Issue.new(:due_date => nil).overdue?
end
end end