changeset 71:7c828d63cb06 luisf

Feature #31: the assigned user is made a watcher of the issue.
author luisf
date Wed, 08 Dec 2010 15:14:02 +0000
parents 35c1d1c098e6
children 45aa8d16ec10
files app/controllers/issues_controller.rb
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/app/controllers/issues_controller.rb	Tue Dec 07 17:42:09 2010 +0000
+++ b/app/controllers/issues_controller.rb	Wed Dec 08 15:14:02 2010 +0000
@@ -138,6 +138,13 @@
       # Adds user to watcher's list
       @issue.add_watcher(User.current)
 
+      # Also adds the assignee to the watcher's list
+       if params[:issue][:assigned_to_id] && !params[:issue][:assigned_to_id].empty?:
+        unless @issue.watcher_ids.include?(params[:issue][:assigned_to_id]):
+          @issue.add_watcher(User.find(params[:issue][:assigned_to_id]))
+        end
+       end
+
       respond_to do |format|
         format.html {
           redirect_to(params[:continue] ?  { :action => 'new', :project_id => @project, :issue => {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?} } :
@@ -279,6 +286,18 @@
     @notes = params[:notes] || (params[:issue].present? ? params[:issue][:notes] : nil)
     @issue.init_journal(User.current, @notes)
     @issue.safe_attributes = params[:issue]
+
+    # tests if the the user assigned_to_id
+    # is in this issues watcher's list
+    # if not, adds it.
+
+    if params[:issue][:assigned_to_id] && !params[:issue][:assigned_to_id].empty?:
+      unless @issue.watcher_ids.include?(params[:issue][:assigned_to_id]):
+        @issue.add_watcher(User.find(params[:issue][:assigned_to_id]))
+      end
+    end
+
+
   end
 
   # TODO: Refactor, lots of extra code in here