Refactoring admin venue menu #304

This commit is contained in:
chrisbr 2014-11-09 18:49:47 +01:00
parent 2c98ba9711
commit e0d39e60eb
13 changed files with 111 additions and 57 deletions

View file

@ -12,6 +12,18 @@ class Venue < ActiveRecord::Base
size: { in: 0..500.kilobytes }
accepts_nested_attributes_for :lodgings, allow_destroy: true
after_update :send_mail_notification
validates :name, :address, presence: true
private
def send_mail_notification
conferences.each do |conference|
Mailbot.delay.send_email_on_venue_update(conference) if venue_notify?(conference)
end
end
def venue_notify?(conference)
(self.name_changed? || self.address_changed?) &&
(!self.name.blank? && !self.address.blank?) &&
@ -20,8 +32,6 @@ class Venue < ActiveRecord::Base
conference.email_settings.venue_update_template)
end
private
# TODO: create a module to be mixed into model to perform same operation
# event.rb has same functionality which can be shared
# TODO: rename guid to UUID as guid is specifically Microsoft term