diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-11-08 13:03:41 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-11-08 13:03:41 +0000 |
commit | d201c54455fd15d0069de5a60bc99a57cc380ba3 (patch) | |
tree | ef8c74e1de77b36bb2548c43a09a21897b9c41ec /app/models/issue.rb | |
parent | 7c14c6d42e469f1cd81b08c059a9717566fe4e1f (diff) | |
download | redmine-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/issue.rb')
-rw-r--r-- | app/models/issue.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index f7b2f8a36..ea6eb1307 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -143,6 +143,14 @@ class Issue < ActiveRecord::Base if start_date && soonest_start && start_date < soonest_start errors.add :start_date, :invalid end + + if fixed_version + if !assignable_versions.include?(fixed_version) + errors.add :fixed_version_id, :inclusion + elsif reopened? && fixed_version.closed? + errors.add_to_base I18n.t(:error_can_not_reopen_issue_on_closed_version) + end + end end def validate_on_create @@ -193,6 +201,18 @@ class Issue < ActiveRecord::Base self.status.is_closed? end + # Return true if the issue is being reopened + def reopened? + if !new_record? && status_id_changed? + status_was = IssueStatus.find_by_id(status_id_was) + status_new = IssueStatus.find_by_id(status_id) + if status_was && status_new && status_was.is_closed? && !status_new.is_closed? + return true + end + end + false + end + # Returns true if the issue is overdue def overdue? !due_date.nil? && (due_date < Date.today) && !status.is_closed? @@ -203,6 +223,11 @@ class Issue < ActiveRecord::Base project.assignable_users end + # Versions that the issue can be assigned to + def assignable_versions + @assignable_versions ||= (project.versions.open + [Version.find_by_id(fixed_version_id_was)]).compact.uniq.sort + end + # Returns true if this issue is blocked by another issue that is still open def blocked? !relations_to.detect {|ir| ir.relation_type == 'blocks' && !ir.issue_from.closed?}.nil? |