summaryrefslogtreecommitdiffstats
path: root/app/models/version.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-11-08 13:03:41 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-11-08 13:03:41 +0000
commitd201c54455fd15d0069de5a60bc99a57cc380ba3 (patch)
treeef8c74e1de77b36bb2548c43a09a21897b9c41ec /app/models/version.rb
parent7c14c6d42e469f1cd81b08c059a9717566fe4e1f (diff)
downloadredmine-d201c54455fd15d0069de5a60bc99a57cc380ba3.tar.gz
redmine-d201c54455fd15d0069de5a60bc99a57cc380ba3.zip
Adds version status to limit issue assignments (#1245).
Available version statuses are: * open: no restriction * locked: can not assign new issues to the version * closed: can not assign new issues and can not reopen assigned issues git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3020 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/version.rb')
-rw-r--r--app/models/version.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/app/models/version.rb b/app/models/version.rb
index 13d33e256..dc72e8212 100644
--- a/app/models/version.rb
+++ b/app/models/version.rb
@@ -22,11 +22,16 @@ class Version < ActiveRecord::Base
acts_as_attachable :view_permission => :view_files,
:delete_permission => :manage_files
+ VERSION_STATUSES = %w(open locked closed)
+
validates_presence_of :name
validates_uniqueness_of :name, :scope => [:project_id]
validates_length_of :name, :maximum => 60
validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => :not_a_date, :allow_nil => true
-
+ validates_inclusion_of :status, :in => VERSION_STATUSES
+
+ named_scope :open, :conditions => {:status => 'open'}
+
def start_date
effective_date
end
@@ -45,6 +50,10 @@ class Version < ActiveRecord::Base
@spent_hours ||= TimeEntry.sum(:hours, :include => :issue, :conditions => ["#{Issue.table_name}.fixed_version_id = ?", id]).to_f
end
+ def closed?
+ status == 'closed'
+ end
+
# Returns true if the version is completed: due date reached and no open issues
def completed?
effective_date && (effective_date <= Date.today) && (open_issues_count == 0)