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

@ -8,14 +8,9 @@ module Admin
def update
@venue = @conference.venue
@venue.assign_attributes(params[:venue])
venue_notify = (@venue.name_changed? || @venue.address_changed?) &&
(!@venue.name.blank? && !@venue.address.blank?) &&
(@conference.email_settings.send_on_venue_update &&
!@conference.email_settings.venue_update_subject.blank? &&
@conference.email_settings.venue_update_template)
send_mail = @venue.venue_notify?(@conference)
if @venue.update_attributes(params[:venue])
Mailbot.delay.send_email_on_venue_update(@conference) if venue_notify
Mailbot.delay.send_email_on_venue_update(@conference) if send_mail
redirect_to(admin_conference_venue_info_path(conference_id: @conference.short_title),
notice: 'Venue was successfully updated.')
else