mirror of
https://github.com/openSUSE/osem.git
synced 2026-05-18 21:46:17 -04:00
Merge pull request #318 from gopesht/notify_on_venue_change
Email notification to all participants on venue update
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
class AddVenueUpdateToEmailSettings < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :email_settings, :send_on_venue_update, :boolean, default: true
|
||||
add_column :email_settings, :venue_update_subject, :string
|
||||
add_column :email_settings, :venue_update_template, :text
|
||||
end
|
||||
end
|
||||
@@ -171,6 +171,9 @@ ActiveRecord::Schema.define(version: 20140714141156) do
|
||||
t.boolean "send_on_updated_conference_registration_dates", default: true
|
||||
t.string "updated_conference_registration_dates_subject"
|
||||
t.text "updated_conference_registration_dates_template"
|
||||
t.boolean "send_on_venue_update", default: true
|
||||
t.string "venue_update_subject"
|
||||
t.text "venue_update_template"
|
||||
end
|
||||
|
||||
create_table "event_attachments", force: true do |t|
|
||||
|
||||
@@ -12,6 +12,9 @@ FactoryGirl.define do
|
||||
updated_conference_dates_subject 'Conference dates have been updated'
|
||||
updated_conference_registration_dates_subject 'Conference registration dates have been updated'
|
||||
updated_conference_registration_dates_template 'Sample Conference\n New Dates: January 17 - 21 2014'
|
||||
send_on_venue_update true
|
||||
venue_update_subject "Venue has been updated"
|
||||
venue_update_template "Venue has been Updated to Sample Location"
|
||||
registration_subject 'Lorem Ipsum Dolsum'
|
||||
registration_email_template 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit'
|
||||
end
|
||||
|
||||
@@ -8,9 +8,9 @@ describe 'admin/emails/index' do
|
||||
assign :settings, @settings
|
||||
render
|
||||
expect(rendered).
|
||||
to have_selector("input[type='checkbox'][value='1']", count: 6)
|
||||
to have_selector("input[type='checkbox'][value='1']", count: 7)
|
||||
expect(rendered).
|
||||
to have_selector("input[checked='checked'][type='checkbox'][value='1']", count: 3)
|
||||
to have_selector("input[checked='checked'][type='checkbox'][value='1']", count: 4)
|
||||
expect(rendered).to include('Lorem Ipsum Dolsum')
|
||||
expect(rendered).
|
||||
to include('Lorem ipsum dolor sit amet, consectetuer adipiscing elit')
|
||||
@@ -18,5 +18,7 @@ describe 'admin/emails/index' do
|
||||
to include('Conference dates have been updated')
|
||||
expect(rendered).
|
||||
to include('Conference registration dates have been updated')
|
||||
expect(rendered).to include("Venue has been updated")
|
||||
expect(rendered).to include("Venue has been Updated to Sample Location")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user