summaryrefslogtreecommitdiffstats
path: root/app/models/version.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-08-12 09:58:38 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-08-12 09:58:38 +0000
commit3c8e7c79b639d32ecd6c8cb81b20fce00a6e722d (patch)
tree5615009119c5fd3d2d935f04defc75c721d5eb34 /app/models/version.rb
parent3be226d0c475359bf9061b4577b7efada397dd0d (diff)
downloadredmine-3c8e7c79b639d32ecd6c8cb81b20fce00a6e722d.tar.gz
redmine-3c8e7c79b639d32ecd6c8cb81b20fce00a6e722d.zip
Overdue versions (date reached and open issues > 0) are now always displayed on the roadmap.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@604 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/version.rb')
-rw-r--r--app/models/version.rb16
1 files changed, 15 insertions, 1 deletions
diff --git a/app/models/version.rb b/app/models/version.rb
index f4a40da67..bc58e0de4 100644
--- a/app/models/version.rb
+++ b/app/models/version.rb
@@ -34,8 +34,22 @@ class Version < ActiveRecord::Base
effective_date
end
+ # Returns true if the version is completed: due date reached and no open issues
def completed?
- effective_date && effective_date <= Date.today
+ effective_date && (effective_date <= Date.today) && (open_issues_count == 0)
+ end
+
+ # Returns true if the version is overdue: due date reached and some open issues
+ def overdue?
+ effective_date && (effective_date < Date.today) && (open_issues_count > 0)
+ end
+
+ def open_issues_count
+ @open_issues_count ||= Issue.count(:all, :conditions => ["fixed_version_id = ? AND is_closed = ?", self.id, false], :include => :status)
+ end
+
+ def closed_issues_count
+ @closed_issues_count ||= Issue.count(:all, :conditions => ["fixed_version_id = ? AND is_closed = ?", self.id, true], :include => :status)
end
def wiki_page