diff options
author | Go MAEDA <maeda@farend.jp> | 2020-02-06 08:19:13 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2020-02-06 08:19:13 +0000 |
commit | b995014c495b36102f36ec80618f50f3763bcd6f (patch) | |
tree | 85c230cf16c300f51f9716299ff7bc48d300c4cf /app/controllers | |
parent | 29433771b45319a0b50f182f0dcaf72db1275a30 (diff) | |
download | redmine-b995014c495b36102f36ec80618f50f3763bcd6f.tar.gz redmine-b995014c495b36102f36ec80618f50f3763bcd6f.zip |
Allow adding user groups as watchers for issues (#4511).
Patch by Yuichi HARADA.
git-svn-id: http://svn.redmine.org/redmine/trunk@19498 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/watchers_controller.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/app/controllers/watchers_controller.rb b/app/controllers/watchers_controller.rb index f0692e31d..e0de27464 100644 --- a/app/controllers/watchers_controller.rb +++ b/app/controllers/watchers_controller.rb @@ -42,7 +42,9 @@ class WatchersController < ApplicationController else user_ids << params[:user_id] end - users = User.active.visible.where(:id => user_ids.flatten.compact.uniq) + user_ids = user_ids.flatten.compact.uniq + users = User.active.visible.where(:id => user_ids).to_a + users += Group.givable.active.visible.where(:id => user_ids).to_a users.each do |user| @watchables.each do |watchable| Watcher.create(:watchable => watchable, :user => user) @@ -59,6 +61,7 @@ class WatchersController < ApplicationController if params[:watcher] user_ids = params[:watcher][:user_ids] || [params[:watcher][:user_id]] @users = User.active.visible.where(:id => user_ids).to_a + @users += Group.givable.active.visible.where(:id => user_ids).to_a end if @users.blank? head 200 @@ -66,7 +69,7 @@ class WatchersController < ApplicationController end def destroy - user = User.find(params[:user_id]) + user = Principal.find(params[:user_id]) @watchables.each do |watchable| watchable.set_watcher(user, false) end @@ -119,13 +122,16 @@ class WatchersController < ApplicationController end def users_for_new_watcher - scope = nil + scope, scope_groups = nil if params[:q].blank? && @project.present? scope = @project.users + scope_groups = @project.principals.merge(Group.givable) else scope = User.all.limit(100) + scope_groups = Group.givable.limit(100) end users = scope.active.visible.sorted.like(params[:q]).to_a + users += scope_groups.active.visible.sorted.like(params[:q]).to_a if @watchables && @watchables.size == 1 users -= @watchables.first.watcher_users end |