From ee46c3570ec5f3948a94adedfdefd734822f95af Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Sat, 25 Apr 2020 08:01:59 +0000 Subject: Use scope assignable_watchers (#4511). Patch by Marius BALTEANU. git-svn-id: http://svn.redmine.org/redmine/trunk@19726 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/watchers_controller.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'app/controllers/watchers_controller.rb') diff --git a/app/controllers/watchers_controller.rb b/app/controllers/watchers_controller.rb index 630566dcd..d68614876 100644 --- a/app/controllers/watchers_controller.rb +++ b/app/controllers/watchers_controller.rb @@ -43,7 +43,7 @@ class WatchersController < ApplicationController user_ids << params[:user_id] end user_ids = user_ids.flatten.compact.uniq - users = Principal.active.visible.where(:id => user_ids).where(:users => {:type => ['User', 'Group']}).to_a + users = Principal.assignable_watchers.where(:id => user_ids).to_a users.each do |user| @watchables.each do |watchable| Watcher.create(:watchable => watchable, :user => user) @@ -59,7 +59,7 @@ class WatchersController < ApplicationController def append if params[:watcher] user_ids = params[:watcher][:user_ids] || [params[:watcher][:user_id]] - @users = Principal.active.visible.where(:id => user_ids).where(:users => {:type => ['User', 'Group']}).to_a + @users = Principal.assignable_watchers.where(:id => user_ids).to_a end if @users.blank? head 200 @@ -122,11 +122,11 @@ class WatchersController < ApplicationController def users_for_new_watcher scope = nil if params[:q].blank? && @project.present? - scope = @project.principals.where(:users => {:type => ['User', 'Group']}) + scope = @project.principals.assignable_watchers else - scope = Principal.where(:users => {:type => ['User', 'Group']}).limit(100) + scope = Principal.assignable_watchers.limit(100) end - users = scope.active.visible.sorted.like(params[:q]).to_a + users = scope.sorted.like(params[:q]).to_a if @watchables && @watchables.size == 1 users -= @watchables.first.watcher_users end -- cgit v1.2.3