Merge pull request #318 from gopesht/notify_on_venue_change
Email notification to all participants on venue update
This commit is contained in:
commit
b2ab893d17
8 changed files with 40 additions and 4 deletions
|
|
@ -6,7 +6,15 @@ class Admin::VenueController < ApplicationController
|
|||
|
||||
def update
|
||||
@venue = @conference.venue
|
||||
if @venue.update_attributes!(params[:venue])
|
||||
@venue.assign_attributes(params[:venue])
|
||||
unless @venue.name.blank? || @venue.address.blank? || @conference.registrations.blank?
|
||||
if @venue.name_changed? || @venue.address_changed? && @conference.email_settings.send_on_venue_update
|
||||
venue_notify = Mailbot.send_email_on_venue_update(@conference)
|
||||
end
|
||||
end
|
||||
|
||||
if @venue.update_attributes(params[:venue])
|
||||
venue_notify.deliver unless venue_notify.blank?
|
||||
redirect_to(admin_conference_venue_info_path(conference_id: @conference.short_title),
|
||||
notice: 'Venue was successfully updated.')
|
||||
else
|
||||
|
|
|
|||
|
|
@ -56,6 +56,15 @@ class Mailbot < ActionMailer::Base
|
|||
end
|
||||
end
|
||||
|
||||
def send_email_on_venue_update(conference)
|
||||
subject = conference.email_settings.venue_update_subject.blank? ? "#{conference.title} location has been changed" : conference.email_settings.venue_update_subject
|
||||
partial = "#{conference.title} new location is: #{conference.venue.name}.\n Address: #{conference.venue.address}\n. For more information please visit #{Rails.application.routes.url_helpers.conference_path(conference.short_title, host: CONFIG['url_for_emails'])}"
|
||||
body = conference.email_settings.venue_update_template.blank? ? partial : "#{conference.email_settings.venue_update_template}\n #{partial}"
|
||||
conference.registrations.each do |u|
|
||||
build_email(conference, u.email, subject, body)
|
||||
end
|
||||
end
|
||||
|
||||
def build_email(conference, to, subject, body)
|
||||
mail(:to => to,
|
||||
:from => conference.contact_email,
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ class EmailSettings < ActiveRecord::Base
|
|||
:confirmed_without_registration_subject,
|
||||
:send_on_updated_conference_dates, :updated_conference_dates_subject,
|
||||
:updated_conference_dates_template, :send_on_updated_conference_registration_dates,
|
||||
:updated_conference_registration_dates_subject, :updated_conference_registration_dates_template
|
||||
:updated_conference_registration_dates_subject, :updated_conference_registration_dates_template,
|
||||
:send_on_venue_update, :venue_update_subject, :venue_update_template
|
||||
|
||||
def get_values(conference, user, event = nil)
|
||||
h = {
|
||||
|
|
|
|||
|
|
@ -41,6 +41,9 @@
|
|||
= f.input :send_on_updated_conference_registration_dates, hint: "This is to notify all participants that the conference registration dates has been changed."
|
||||
= f.input :updated_conference_registration_dates_subject
|
||||
= f.input :updated_conference_registration_dates_template, :input_html => { :rows => 10, :cols => 20 }
|
||||
= f.input :send_on_venue_update, hint: 'Send an email on updating the Venue.'
|
||||
= f.input :venue_update_subject
|
||||
= f.input :venue_update_template, :input_html => { :rows => 10, :cols => 20 }
|
||||
= f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"}
|
||||
|
||||
:javascript
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue