Sha256: 8c3115b2b5469171de34d825867fcc9b672b8b45120afee574e8de4848c0814a
Contents?: true
Size: 1.14 KB
Versions: 7
Compression:
Stored size: 1.14 KB
Contents
# Copyright (c) 2008-2013 Michael Dvorkin and contributors. # # Fat Free CRM is freely distributable under the terms of MIT license. # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php #------------------------------------------------------------------------------ class EntityObserver < ActiveRecord::Observer observe :account, :contact, :lead, :opportunity def after_create(item) send_notification_to_assignee(item) if current_user != item.assignee end def after_update(item) if item.assigned_to_changed? && item.assignee != current_user send_notification_to_assignee(item) end end private def send_notification_to_assignee(item) UserMailer.assigned_entity_notification(item, current_user).deliver if item.assignee.present? && current_user.present? end def current_user # this deals with whodunnit inconsistencies, where in some cases it's set to a user's id and others the user object itself user_id_or_user = PaperTrail.whodunnit if user_id_or_user.is_a?(User) user_id_or_user elsif user_id_or_user.is_a?(String) User.find_by_id(user_id_or_user.to_i) end end end
Version data entries
7 entries across 7 versions & 1 rubygems