diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-08-25 17:45:51 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-08-25 17:45:51 +0000 |
commit | 4fa51992b5bfe777601e1fb30e0ea3941f392212 (patch) | |
tree | 25e1886a9503021ee79514690d97b9f424fd7d50 /app/models/issue.rb | |
parent | b96dc97d150bf9480f18347be8c74d1b27dc1887 (diff) | |
download | redmine-4fa51992b5bfe777601e1fb30e0ea3941f392212.tar.gz redmine-4fa51992b5bfe777601e1fb30e0ea3941f392212.zip |
Automatic closing of duplicate issues.
When closing an issue, all related issues marked as duplicates are now also closed.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@663 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/issue.rb')
-rw-r--r-- | app/models/issue.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index 0e9e7745a..65b34cb92 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -94,7 +94,19 @@ class Issue < ActiveRecord::Base end def after_save + # Update start/due dates of following issues relations_from.each(&:set_issue_to_dates) + + # Close duplicates if the issue was closed + if @issue_before_change && !@issue_before_change.closed? && self.closed? + duplicates.each do |duplicate| + # Don't re-close it if it's already closed + next if duplicate.closed? + # Same user and notes + duplicate.init_journal(@current_journal.user, @current_journal.notes) + duplicate.update_attribute :status, self.status + end + end end def custom_value_for(custom_field) @@ -110,6 +122,11 @@ class Issue < ActiveRecord::Base @current_journal end + # Return true if the issue is closed, otherwise false + def closed? + self.status.is_closed? + end + # Users the issue can be assigned to def assignable_users project.members.select {|m| m.role.assignable?}.collect {|m| m.user} @@ -132,6 +149,11 @@ class Issue < ActiveRecord::Base dependencies end + # Returns an array of the duplicate issues + def duplicates + relations.select {|r| r.relation_type == IssueRelation::TYPE_DUPLICATES}.collect {|r| r.other_issue(self)} + end + def duration (start_date && due_date) ? due_date - start_date : 0 end |