Moving notifications to models

This commit is contained in:
Gopesh Tulsyan 2014-08-12 16:04:24 +05:30
parent a39f4cf0dd
commit ebdf0df410
6 changed files with 86 additions and 18 deletions

View file

@ -12,6 +12,14 @@ class Venue < ActiveRecord::Base
size: { in: 0..500.kilobytes }
accepts_nested_attributes_for :lodgings, allow_destroy: true
def venue_notify?(conference)
(self.name_changed? || self.address_changed?) &&
(!self.name.blank? && !self.address.blank?) &&
(conference.email_settings.send_on_venue_update &&
!conference.email_settings.venue_update_subject.blank? &&
conference.email_settings.venue_update_template)
end
private
# TODO: create a module to be mixed into model to perform same operation