diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-04-21 12:08:31 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-04-21 12:08:31 +0000 |
commit | 2fb84af3e91dc17aa0f84a8fa0e02cabe2ac712c (patch) | |
tree | 5d90bc5dec82cac5531dd7b14c65f9d35ee64dec /app | |
parent | 907f906ec6e0fb60cbbd4abe7b579c59d78405d4 (diff) | |
download | redmine-2fb84af3e91dc17aa0f84a8fa0e02cabe2ac712c.tar.gz redmine-2fb84af3e91dc17aa0f84a8fa0e02cabe2ac712c.zip |
Added "Watch" functionality on issues. It allows users to receive mail notifications about issue changes.
For now, it's only usefull for users who are not members of the project, since members receive notifications for each issue (this behaviour will change).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@453 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/watchers_controller.rb | 38 | ||||
-rw-r--r-- | app/helpers/watchers_helper.rb | 19 | ||||
-rw-r--r-- | app/models/issue.rb | 2 | ||||
-rw-r--r-- | app/models/mailer.rb | 2 | ||||
-rw-r--r-- | app/models/watcher.rb | 23 | ||||
-rw-r--r-- | app/views/issues/show.rhtml | 7 |
6 files changed, 91 insertions, 0 deletions
diff --git a/app/controllers/watchers_controller.rb b/app/controllers/watchers_controller.rb new file mode 100644 index 000000000..09ec5bcd7 --- /dev/null +++ b/app/controllers/watchers_controller.rb @@ -0,0 +1,38 @@ +# redMine - project management software +# Copyright (C) 2006-2007 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class WatchersController < ApplicationController + layout 'base' + 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 + end + + def remove + @issue.remove_watcher(logged_in_user) + redirect_to :controller => 'issues', :action => 'show', :id => @issue + end + +private + + def find_project + @issue = Issue.find(params[:issue_id]) + @project = @issue.project + end +end diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb new file mode 100644 index 000000000..23f767611 --- /dev/null +++ b/app/helpers/watchers_helper.rb @@ -0,0 +1,19 @@ +# redMine - project management software +# Copyright (C) 2006-2007 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +module WatchersHelper +end diff --git a/app/models/issue.rb b/app/models/issue.rb index bb7797c40..0f44cdd30 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -32,6 +32,8 @@ class Issue < ActiveRecord::Base has_many :custom_values, :dependent => :delete_all, :as => :customized has_many :custom_fields, :through => :custom_values + acts_as_watchable + validates_presence_of :subject, :description, :priority, :tracker, :author, :status validates_inclusion_of :done_ratio, :in => 0..100 validates_associated :custom_values, :on => :update diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 36bcddc2a..5d835289a 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -32,6 +32,8 @@ class Mailer < ActionMailer::Base # Sends to all project members issue = journal.journalized @recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }.compact + # Watchers in cc + @cc = issue.watcher_recipients - @recipients @from = Setting.mail_from @subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}" @body['issue'] = issue diff --git a/app/models/watcher.rb b/app/models/watcher.rb new file mode 100644 index 000000000..cb6ff52ea --- /dev/null +++ b/app/models/watcher.rb @@ -0,0 +1,23 @@ +# redMine - project management software +# Copyright (C) 2006-2007 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class Watcher < ActiveRecord::Base + belongs_to :watchable, :polymorphic => true + belongs_to :user + + validates_uniqueness_of :user_id, :scope => [:watchable_type, :watchable_id] +end diff --git a/app/views/issues/show.rhtml b/app/views/issues/show.rhtml index a5569c9d4..3c1ac0e2e 100644 --- a/app/views/issues/show.rhtml +++ b/app/views/issues/show.rhtml @@ -53,6 +53,13 @@ end %> <div class="contextual"> <%= link_to_if_authorized l(:button_edit), {:controller => 'issues', :action => 'edit', :id => @issue}, :class => 'icon icon-edit' %> <%= link_to_if_authorized l(:button_log_time), {:controller => 'timelog', :action => 'edit', :issue_id => @issue}, :class => 'icon icon-time' %> +<% if @logged_in_user %> + <% if @issue.watched_by?(@logged_in_user) %> +<%= link_to l(:button_unwatch), {:controller => 'watchers', :action => 'remove', :issue_id => @issue}, :class => 'icon icon-fav' %> + <% else %> +<%= link_to l(:button_watch), {:controller => 'watchers', :action => 'add', :issue_id => @issue}, :class => 'icon icon-fav' %> + <% end %> +<% end %> <%= link_to_if_authorized l(:button_move), {:controller => 'projects', :action => 'move_issues', :id => @project, "issue_ids[]" => @issue.id }, :class => 'icon icon-move' %> <%= link_to_if_authorized l(:button_delete), {:controller => 'issues', :action => 'destroy', :id => @issue}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> </div> |