Added watchers for message boards (watchers controller modified to support any watchable model).
No notification yet when a new message is posted. git-svn-id: http://redmine.rubyforge.org/svn/trunk@530 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -25,6 +25,8 @@ class BoardsController < ApplicationController
|
||||
include MessagesHelper
|
||||
helper :sort
|
||||
include SortHelper
|
||||
helper :watchers
|
||||
include WatchersHelper
|
||||
|
||||
def index
|
||||
@boards = @project.boards
|
||||
|
||||
@@ -27,6 +27,8 @@ class IssuesController < ApplicationController
|
||||
include IfpdfHelper
|
||||
helper :issue_relations
|
||||
include IssueRelationsHelper
|
||||
helper :watchers
|
||||
include WatchersHelper
|
||||
|
||||
def show
|
||||
@status_options = @issue.status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker) if logged_in_user
|
||||
|
||||
@@ -20,19 +20,30 @@ class WatchersController < ApplicationController
|
||||
before_filter :require_login, :find_project, :check_project_privacy
|
||||
|
||||
def add
|
||||
@issue.add_watcher(logged_in_user)
|
||||
redirect_to :controller => 'issues', :action => 'show', :id => @issue
|
||||
user = logged_in_user
|
||||
@watched.add_watcher(user)
|
||||
respond_to do |format|
|
||||
format.html { render :text => 'Watcher added.', :layout => true }
|
||||
format.js { render(:update) {|page| page.replace_html 'watcher', watcher_link(@watched, user)} }
|
||||
end
|
||||
end
|
||||
|
||||
def remove
|
||||
@issue.remove_watcher(logged_in_user)
|
||||
redirect_to :controller => 'issues', :action => 'show', :id => @issue
|
||||
user = logged_in_user
|
||||
@watched.remove_watcher(user)
|
||||
respond_to do |format|
|
||||
format.html { render :text => 'Watcher removed.', :layout => true }
|
||||
format.js { render(:update) {|page| page.replace_html 'watcher', watcher_link(@watched, user)} }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_project
|
||||
@issue = Issue.find(params[:issue_id])
|
||||
@project = @issue.project
|
||||
klass = Object.const_get(params[:object_type].camelcase)
|
||||
return false unless klass.respond_to?('watched_by')
|
||||
@watched = klass.find(params[:object_id])
|
||||
@project = @watched.project
|
||||
rescue
|
||||
render_404
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user