##// END OF EJS Templates
Perf: don't load all projects....
Jean-Philippe Lang -
r11726:32464f491251
parent child
Show More
@@ -348,8 +348,7 class Issue < ActiveRecord::Base
348 348 if issue.new_record?
349 349 issue.copy?
350 350 elsif user.allowed_to?(:move_issues, issue.project)
351 projects = Issue.allowed_target_projects_on_move(user)
352 projects.include?(issue.project) && projects.size > 1
351 Issue.allowed_target_projects_on_move.count > 1
353 352 end
354 353 }
355 354
@@ -416,7 +415,7 class Issue < ActiveRecord::Base
416 415
417 416 # Project and Tracker must be set before since new_statuses_allowed_to depends on it.
418 417 if (p = attrs.delete('project_id')) && safe_attribute?('project_id')
419 if allowed_target_projects(user).collect(&:id).include?(p.to_i)
418 if allowed_target_projects(user).where(:id => p.to_i).exists?
420 419 self.project_id = p
421 420 end
422 421 end
@@ -1184,18 +1183,18 class Issue < ActiveRecord::Base
1184 1183 end
1185 1184 # End ReportsController extraction
1186 1185
1187 # Returns an array of projects that user can assign the issue to
1186 # Returns a scope of projects that user can assign the issue to
1188 1187 def allowed_target_projects(user=User.current)
1189 1188 if new_record?
1190 Project.all(:conditions => Project.allowed_to_condition(user, :add_issues))
1189 Project.where(Project.allowed_to_condition(user, :add_issues))
1191 1190 else
1192 1191 self.class.allowed_target_projects_on_move(user)
1193 1192 end
1194 1193 end
1195 1194
1196 # Returns an array of projects that user can move issues to
1195 # Returns a scope of projects that user can move issues to
1197 1196 def self.allowed_target_projects_on_move(user=User.current)
1198 Project.all(:conditions => Project.allowed_to_condition(user, :move_issues))
1197 Project.where(Project.allowed_to_condition(user, :move_issues))
1199 1198 end
1200 1199
1201 1200 private
General Comments 0
You need to be logged in to leave comments. Login now