summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-10-25 12:11:53 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-10-25 12:11:53 +0000
commit97b4e754787dea8d56feec95a433648839d70ff0 (patch)
tree7a00daa88cb5f5de965818a7b72b86661c6303c8 /app
parent6fedbf60d5a9bb2747b1e250ffc9f5f4947676f6 (diff)
downloadredmine-97b4e754787dea8d56feec95a433648839d70ff0.tar.gz
redmine-97b4e754787dea8d56feec95a433648839d70ff0.zip
Add a permission to remove issue watchers (#2450).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2977 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/controllers/watchers_controller.rb14
-rw-r--r--app/helpers/watchers_helper.rb17
2 files changed, 29 insertions, 2 deletions
diff --git a/app/controllers/watchers_controller.rb b/app/controllers/watchers_controller.rb
index 8e6ee3a9e..3d4ed54dd 100644
--- a/app/controllers/watchers_controller.rb
+++ b/app/controllers/watchers_controller.rb
@@ -18,7 +18,7 @@
class WatchersController < ApplicationController
before_filter :find_project
before_filter :require_login, :check_project_privacy, :only => [:watch, :unwatch]
- before_filter :authorize, :only => :new
+ before_filter :authorize, :only => [:new, :destroy]
verify :method => :post,
:only => [ :watch, :unwatch ],
@@ -48,6 +48,18 @@ class WatchersController < ApplicationController
render :text => 'Watcher added.', :layout => true
end
+ def destroy
+ @watched.set_watcher(User.find(params[:user_id]), false) if request.post?
+ respond_to do |format|
+ format.html { redirect_to :back }
+ format.js do
+ render :update do |page|
+ page.replace_html 'watchers', :partial => 'watchers/watchers', :locals => {:watched => @watched}
+ end
+ end
+ end
+ end
+
private
def find_project
klass = Object.const_get(params[:object_type].camelcase)
diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb
index f4767ebed..333b0d299 100644
--- a/app/helpers/watchers_helper.rb
+++ b/app/helpers/watchers_helper.rb
@@ -36,6 +36,21 @@ module WatchersHelper
# Returns a comma separated list of users watching the given object
def watchers_list(object)
- object.watcher_users.collect {|u| content_tag('span', link_to_user(u), :class => 'user') }.join(",\n")
+ remove_allowed = User.current.allowed_to?("delete_#{object.class.name.underscore}_watchers".to_sym, object.project)
+ object.watcher_users.collect do |user|
+ s = content_tag('span', link_to_user(user), :class => 'user')
+ if remove_allowed
+ url = {:controller => 'watchers',
+ :action => 'destroy',
+ :object_type => object.class.to_s.underscore,
+ :object_id => object.id,
+ :user_id => user}
+ s += ' ' + link_to_remote(image_tag('delete.png'),
+ {:url => url},
+ :href => url_for(url),
+ :style => "vertical-align: middle")
+ end
+ s
+ end.join(",\n")
end
end