From 5ffd9760860ac83a7e24ddc4d62822b3a18db0b7 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 14 Mar 2012 16:39:59 +0600 Subject: [PATCH 1/2] [refs #194] fixed remove executor from issue --- app/models/activity_feed_observer.rb | 2 +- app/models/issue.rb | 2 +- app/views/issues/_manage_sidebar.html.haml | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/activity_feed_observer.rb b/app/models/activity_feed_observer.rb index d6dad75b0..07cac2544 100644 --- a/app/models/activity_feed_observer.rb +++ b/app/models/activity_feed_observer.rb @@ -107,7 +107,7 @@ class ActivityFeedObserver < ActiveRecord::Observer def after_update(record) case record.class.to_s when 'Issue' - if record.user_id_was != record.user_id + if record.user_id && record.user_id_was != record.user_id UserMailer.delay.issue_assign_notification(record, record.user) if record.user.notifier.issue_assign && record.user.notifier.can_notify ActivityFeed.create( :user => record.user, diff --git a/app/models/issue.rb b/app/models/issue.rb index 492faa1cd..df66eba3e 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -79,7 +79,7 @@ class Issue < ActiveRecord::Base end def subscribe_issue_assigned_user - if self.user_id_was != self.user_id + if self.user_id && self.user_id_was != self.user_id self.subscribes.where(:user_id => self.user_id_was).first.destroy unless self.user_id_was.blank? if self.user.notifier.issue_assign && !self.subscribes.exists?(:user_id => self.user_id) self.subscribes.create(:user_id => self.user_id) diff --git a/app/views/issues/_manage_sidebar.html.haml b/app/views/issues/_manage_sidebar.html.haml index bd70ac04c..6cbb2cf42 100644 --- a/app/views/issues/_manage_sidebar.html.haml +++ b/app/views/issues/_manage_sidebar.html.haml @@ -14,6 +14,7 @@ - if @issue.persisted? -if can_manage =form_for :issue, :url => [@project, @issue], :method => :put, :html => { :class => 'edit_executor issue'} do |f| + =hidden_field_tag "user-default_executor", nil, :name => 'issue[user_id]' .current_executor - if @issue.user #user-0.people.nopointer From 4b8e9682b5e8ecffa9d6b73b859c19945c69038d Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 14 Mar 2012 16:53:23 +0600 Subject: [PATCH 2/2] [refs #194] some refactor --- app/models/activity_feed_observer.rb | 4 ++-- app/models/issue.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/activity_feed_observer.rb b/app/models/activity_feed_observer.rb index 07cac2544..2261fcbac 100644 --- a/app/models/activity_feed_observer.rb +++ b/app/models/activity_feed_observer.rb @@ -22,7 +22,7 @@ class ActivityFeedObserver < ActiveRecord::Observer ) end - if record.user_id_was != record.user_id + if record.user_id_changed? UserMailer.delay.issue_assign_notification(record, record.user) if record.user.notifier.issue_assign && record.user.notifier.can_notify ActivityFeed.create( :user => record.user, @@ -107,7 +107,7 @@ class ActivityFeedObserver < ActiveRecord::Observer def after_update(record) case record.class.to_s when 'Issue' - if record.user_id && record.user_id_was != record.user_id + if record.user_id && record.user_id_changed? UserMailer.delay.issue_assign_notification(record, record.user) if record.user.notifier.issue_assign && record.user.notifier.can_notify ActivityFeed.create( :user => record.user, diff --git a/app/models/issue.rb b/app/models/issue.rb index df66eba3e..d4f5f5a62 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -79,7 +79,7 @@ class Issue < ActiveRecord::Base end def subscribe_issue_assigned_user - if self.user_id && self.user_id_was != self.user_id + if self.user_id && self.user_id_changed? self.subscribes.where(:user_id => self.user_id_was).first.destroy unless self.user_id_was.blank? if self.user.notifier.issue_assign && !self.subscribes.exists?(:user_id => self.user_id) self.subscribes.create(:user_id => self.user_id)