summaryrefslogtreecommitdiffstats
path: root/app/controllers/watchers_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/watchers_controller.rb')
-rw-r--r--app/controllers/watchers_controller.rb12
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