mirror of
https://github.com/meineerde/redmine.git
synced 2026-01-02 13:49:42 +00:00
Preload project when possible (#5754).
git-svn-id: http://svn.redmine.org/redmine/trunk@15314 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
14234eae39
commit
933dc946d4
@ -131,7 +131,12 @@ class WatchersController < ApplicationController
|
||||
klass = Object.const_get(params[:object_type].camelcase) rescue nil
|
||||
return unless klass && klass.respond_to?('watched_by')
|
||||
|
||||
objects = klass.where(:id => Array.wrap(params[:object_id])).to_a
|
||||
scope = klass.where(:id => Array.wrap(params[:object_id]))
|
||||
if klass.reflect_on_association(:project)
|
||||
scope = scope.preload(:project => :enabled_modules)
|
||||
end
|
||||
objects = scope.to_a
|
||||
|
||||
raise Unauthorized if objects.any? do |w|
|
||||
if w.respond_to?(:visible?)
|
||||
!w.visible?
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user