##// END OF EJS Templates
Redirects back after clicking watch/unwatch links without javascript (#1337)....
Jean-Philippe Lang -
r1593:b29b39290a35
parent child
Show More
@@ -1,49 +1,53
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 class WatchersController < ApplicationController
19 19 layout 'base'
20 20 before_filter :require_login, :find_project, :check_project_privacy
21 21
22 22 def add
23 23 user = User.current
24 24 @watched.add_watcher(user)
25 25 respond_to do |format|
26 format.html { render :text => 'Watcher added.', :layout => true }
26 format.html { redirect_to :back }
27 27 format.js { render(:update) {|page| page.replace_html 'watcher', watcher_link(@watched, user)} }
28 28 end
29 rescue RedirectBackError
30 render :text => 'Watcher added.', :layout => true
29 31 end
30 32
31 33 def remove
32 34 user = User.current
33 35 @watched.remove_watcher(user)
34 36 respond_to do |format|
35 format.html { render :text => 'Watcher removed.', :layout => true }
37 format.html { redirect_to :back }
36 38 format.js { render(:update) {|page| page.replace_html 'watcher', watcher_link(@watched, user)} }
37 39 end
40 rescue RedirectBackError
41 render :text => 'Watcher removed.', :layout => true
38 42 end
39 43
40 44 private
41 45 def find_project
42 46 klass = Object.const_get(params[:object_type].camelcase)
43 47 return false unless klass.respond_to?('watched_by')
44 48 @watched = klass.find(params[:object_id])
45 49 @project = @watched.project
46 50 rescue
47 51 render_404
48 52 end
49 53 end
General Comments 0
You need to be logged in to leave comments. Login now