2011-10-14 21:45:58 +01:00
|
|
|
class EventLogObserver < ActiveRecord::Observer
|
2011-11-11 17:13:09 +00:00
|
|
|
observe :user, :private_user, :platform, :repository, :project, :product, :build_list, :auto_build_list, :product_build_list
|
2011-10-14 21:45:58 +01:00
|
|
|
|
|
|
|
def after_create(record)
|
|
|
|
ActiveSupport::Notifications.instrument("event_log.observer", :object => record)
|
|
|
|
end
|
|
|
|
|
2011-10-28 23:31:47 +01:00
|
|
|
def before_update(record)
|
2011-11-07 22:54:25 +00:00
|
|
|
case record.class.to_s
|
|
|
|
when 'BuildList'
|
2011-11-11 17:13:09 +00:00
|
|
|
if record.status_changed? and [BuildList::BUILD_CANCELED, BuildList::BUILD_PUBLISHED].include?(record.status)
|
2011-10-28 23:31:47 +01:00
|
|
|
ActiveSupport::Notifications.instrument("event_log.observer", :object => record)
|
|
|
|
end
|
2011-11-07 22:54:25 +00:00
|
|
|
when 'Platform'
|
|
|
|
if record.visibility_changed?
|
|
|
|
ActiveSupport::Notifications.instrument "event_log.observer", :object => record,
|
|
|
|
:message => I18n.t("activerecord.attributes.platform.visibility_types.#{record.visibility}")
|
|
|
|
end
|
2011-10-28 23:31:47 +01:00
|
|
|
end
|
|
|
|
end
|
2011-10-14 21:45:58 +01:00
|
|
|
|
|
|
|
def after_destroy(record)
|
|
|
|
ActiveSupport::Notifications.instrument("event_log.observer", :object => record)
|
|
|
|
end
|
|
|
|
end
|