@@ -344,8 +344,8 class Issue < ActiveRecord::Base | |||||
344 | # fixed_version that is outside of the issue's project hierarchy. |
|
344 | # fixed_version that is outside of the issue's project hierarchy. | |
345 | # |
|
345 | # | |
346 | # OPTIMIZE: does a full table scan of Issues with a fixed_version. |
|
346 | # OPTIMIZE: does a full table scan of Issues with a fixed_version. | |
347 |
def self.update_fixed_versions_from_ |
|
347 | def self.update_fixed_versions_from_sharing_change(conditions=nil) | |
348 |
Issue.all(:conditions => |
|
348 | Issue.all(:conditions => merge_conditions('fixed_version_id IS NOT NULL', conditions), | |
349 | :include => [:project, :fixed_version] |
|
349 | :include => [:project, :fixed_version] | |
350 | ).each do |issue| |
|
350 | ).each do |issue| | |
351 | next if issue.project.nil? || issue.fixed_version.nil? |
|
351 | next if issue.project.nil? || issue.fixed_version.nil? |
@@ -304,7 +304,7 class Project < ActiveRecord::Base | |||||
304 | # move_to_child_of adds the project in last (ie.right) position |
|
304 | # move_to_child_of adds the project in last (ie.right) position | |
305 | move_to_child_of(p) |
|
305 | move_to_child_of(p) | |
306 | end |
|
306 | end | |
307 |
Issue.update_fixed_versions_from_ |
|
307 | Issue.update_fixed_versions_from_sharing_change | |
308 | true |
|
308 | true | |
309 | else |
|
309 | else | |
310 | # Can not move to the given target |
|
310 | # Can not move to the given target |
@@ -17,7 +17,7 | |||||
17 |
|
17 | |||
18 | class Version < ActiveRecord::Base |
|
18 | class Version < ActiveRecord::Base | |
19 | before_destroy :check_integrity |
|
19 | before_destroy :check_integrity | |
20 |
after_update :update_issue |
|
20 | after_update :update_issues_from_sharing_change | |
21 | belongs_to :project |
|
21 | belongs_to :project | |
22 | has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id' |
|
22 | has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id' | |
23 | acts_as_customizable |
|
23 | acts_as_customizable | |
@@ -161,9 +161,13 private | |||||
161 | end |
|
161 | end | |
162 |
|
162 | |||
163 | # Update the issue's fixed versions. Used if a version's sharing changes. |
|
163 | # Update the issue's fixed versions. Used if a version's sharing changes. | |
164 |
def update_issue |
|
164 | def update_issues_from_sharing_change | |
165 | if sharing_changed? |
|
165 | if sharing_changed? | |
166 | Issue.update_fixed_versions_from_project_hierarchy_change |
|
166 | if VERSION_SHARINGS.index(sharing_was).nil? || | |
|
167 | VERSION_SHARINGS.index(sharing).nil? || | |||
|
168 | VERSION_SHARINGS.index(sharing_was) > VERSION_SHARINGS.index(sharing) | |||
|
169 | Issue.update_fixed_versions_from_sharing_change ['fixed_version_id = ?', id] | |||
|
170 | end | |||
167 | end |
|
171 | end | |
168 | end |
|
172 | end | |
169 |
|
173 |
General Comments 0
You need to be logged in to leave comments.
Login now