Ability to add non-member users as watchers (#5159).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8592 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2012-01-09 18:37:16 +00:00
parent c22f60271f
commit 1b1c510ff9
9 changed files with 101 additions and 28 deletions
+23 -3
View File
@@ -37,13 +37,28 @@ class WatchersController < ApplicationController
end
def new
@watcher = Watcher.new(params[:watcher])
@watcher.watchable = @watched
@watcher.save if request.post?
respond_to do |format|
format.js do
render :update do |page|
page.replace_html 'ajax-modal', :partial => 'watchers/new', :locals => {:watched => @watched}
page << "showModal('ajax-modal', '400px');"
end
end
end
end
def create
if params[:watcher].is_a?(Hash) && request.post?
user_ids = params[:watcher][:user_ids] || [params[:watcher][:user_id]]
user_ids.each do |user_id|
Watcher.create(:watchable => @watched, :user_id => user_id)
end
end
respond_to do |format|
format.html { redirect_to :back }
format.js do
render :update do |page|
page.replace_html 'ajax-modal', :partial => 'watchers/new', :locals => {:watched => @watched}
page.replace_html 'watchers', :partial => 'watchers/watchers', :locals => {:watched => @watched}
end
end
@@ -64,6 +79,11 @@ class WatchersController < ApplicationController
end
end
def autocomplete_for_user
@users = User.active.like(params[:q]).find(:all, :limit => 100) - @watched.watcher_users
render :layout => false
end
private
def find_project
klass = Object.const_get(params[:object_type].camelcase)