Merge 4126aaa116 into 609f2fd564
This commit is contained in:
commit
0ca2c61e2d
7 changed files with 93 additions and 35 deletions
|
|
@ -1,4 +1,40 @@
|
||||||
$(function() {
|
$(function() {
|
||||||
|
/**
|
||||||
|
* Adds the default template as value to the regarding email textarea field.
|
||||||
|
*/
|
||||||
|
$(".load_template").on('click', function(){
|
||||||
|
var template = $(this).data('template');
|
||||||
|
var textarea_name = $(this).data('name');
|
||||||
|
$('#' + textarea_name).val(template);
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggle the required attribute on click on_send_email radio button.
|
||||||
|
*/
|
||||||
|
$('.send_on_radio').click(function() {
|
||||||
|
toggle_required_for_mail_subjects($(this))
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds required attribute to on_send_email radio button if necessary.
|
||||||
|
*/
|
||||||
|
$('.send_on_radio').each(function() {
|
||||||
|
toggle_required_for_mail_subjects($(this))
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggle the required attribute helper function.
|
||||||
|
*/
|
||||||
|
function toggle_required_for_mail_subjects($this){
|
||||||
|
var name = $this.data('name');
|
||||||
|
if($this.is(':checked')) {
|
||||||
|
$('#' + name).prop('required', true);
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
$('#' + name).removeAttr('required');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens a prompt with the URL to copy to clipboard.
|
* Opens a prompt with the URL to copy to clipboard.
|
||||||
* Used in the campaign index view.
|
* Used in the campaign index view.
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,9 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def accept
|
def accept
|
||||||
update_state(params[:id], :accept, 'Event accepted!', true)
|
event = Event.find(params[:id])
|
||||||
|
subject = event.conference.email_settings.accepted_subject.blank?
|
||||||
|
update_state(params[:id], :accept, 'Event accepted!', true, subject)
|
||||||
end
|
end
|
||||||
|
|
||||||
def confirm
|
def confirm
|
||||||
|
|
@ -139,7 +141,9 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def reject
|
def reject
|
||||||
update_state(params[:id], :reject, 'Event rejected!', true)
|
event = Event.find(params[:id])
|
||||||
|
subject = event.conference.email_settings.rejected_subject.blank?
|
||||||
|
update_state(params[:id], :reject, 'Event rejected!', true, subject)
|
||||||
end
|
end
|
||||||
|
|
||||||
def restart
|
def restart
|
||||||
|
|
@ -167,10 +171,11 @@ module Admin
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def update_state(id, transition, notice, mail = false)
|
def update_state(id, transition, notice, mail = false, subject = nil)
|
||||||
event = Event.find(id)
|
event = Event.find(id)
|
||||||
if mail
|
if mail && params[:send_mail].blank? && event && subject
|
||||||
check_mail_settings(event)
|
return redirect_to(admin_conference_events_path(conference_id: @conference.short_title),
|
||||||
|
notice: 'Please add a Subject before sending Mails!') && return
|
||||||
end
|
end
|
||||||
if event
|
if event
|
||||||
begin
|
begin
|
||||||
|
|
@ -182,25 +187,13 @@ module Admin
|
||||||
end
|
end
|
||||||
event.save
|
event.save
|
||||||
rescue Transitions::InvalidTransition => e
|
rescue Transitions::InvalidTransition => e
|
||||||
redirect_to(
|
notice = "Update state failed. #{e.message}"
|
||||||
admin_conference_events_path(conference_id: @conference.short_title),
|
|
||||||
notice: "Update state failed. #{e.message}") && return
|
|
||||||
end
|
end
|
||||||
redirect_to(admin_conference_events_path(conference_id: @conference.short_title),
|
|
||||||
notice: notice)
|
|
||||||
else
|
else
|
||||||
redirect_to(admin_conference_events_path(conference_id: @conference.short_title),
|
notice = 'Error! Could not find event!'
|
||||||
notice: 'Error! Could not find event!')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def check_mail_settings(event)
|
|
||||||
if !params[:send_mail].blank? && event &&
|
|
||||||
event.conference.email_settings.rejected_email_template.nil? &&
|
|
||||||
event.conference.email_settings.accepted_email_template.nil?
|
|
||||||
redirect_to(admin_conference_events_path(conference_id: @conference.short_title),
|
|
||||||
notice: 'Update Email Template before Sending Mails') && return
|
|
||||||
end
|
end
|
||||||
|
redirect_to(admin_conference_events_path(conference_id: @conference.short_title),
|
||||||
|
notice: notice) && return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@ class ProposalController < ApplicationController
|
||||||
if @event.transition_possible? :confirm
|
if @event.transition_possible? :confirm
|
||||||
begin
|
begin
|
||||||
@event.confirm!
|
@event.confirm!
|
||||||
rescue InvalidTransition => e
|
rescue Transitions::InvalidTransition => e
|
||||||
redirect_to(conference_proposal_index_path(conference_id: @conference.short_title),
|
redirect_to(conference_proposal_index_path(conference_id: @conference.short_title),
|
||||||
alert: "Event was NOT confirmed: #{e.message}")
|
alert: "Event was NOT confirmed: #{e.message}")
|
||||||
return
|
return
|
||||||
|
|
@ -187,7 +187,7 @@ class ProposalController < ApplicationController
|
||||||
begin
|
begin
|
||||||
@event.restart
|
@event.restart
|
||||||
@event.save
|
@event.save
|
||||||
rescue InvalidTransition => e
|
rescue Transitions::InvalidTransition => e
|
||||||
redirect_to(conference_proposal_index_path(conference_id: @conference.short_title),
|
redirect_to(conference_proposal_index_path(conference_id: @conference.short_title),
|
||||||
alert: "Event was NOT restarted: #{e.message}")
|
alert: "Event was NOT restarted: #{e.message}")
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,9 @@ class Event < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_confirmation
|
def process_confirmation
|
||||||
if conference.email_settings.send_on_confirmed_without_registration?
|
if conference.email_settings.send_on_confirmed_without_registration? &&
|
||||||
|
conference.email_settings.confirmed_email_template &&
|
||||||
|
conference.email_settings.confirmed_without_registration_subject
|
||||||
if conference.registrations.where(user_id: submitter.id).first.nil?
|
if conference.registrations.where(user_id: submitter.id).first.nil?
|
||||||
Mailbot.confirm_reminder_mail(self).deliver
|
Mailbot.confirm_reminder_mail(self).deliver
|
||||||
end
|
end
|
||||||
|
|
@ -133,6 +135,8 @@ class Event < ActiveRecord::Base
|
||||||
|
|
||||||
def process_acceptance(options)
|
def process_acceptance(options)
|
||||||
if conference.email_settings.send_on_accepted &&
|
if conference.email_settings.send_on_accepted &&
|
||||||
|
conference.email_settings.accepted_email_template &&
|
||||||
|
conference.email_settings.accepted_subject &&
|
||||||
options[:send_mail].blank?
|
options[:send_mail].blank?
|
||||||
Rails.logger.debug 'Sending event acceptance mail'
|
Rails.logger.debug 'Sending event acceptance mail'
|
||||||
Mailbot.acceptance_mail(self).deliver
|
Mailbot.acceptance_mail(self).deliver
|
||||||
|
|
@ -141,6 +145,8 @@ class Event < ActiveRecord::Base
|
||||||
|
|
||||||
def process_rejection(options)
|
def process_rejection(options)
|
||||||
if conference.email_settings.send_on_rejected &&
|
if conference.email_settings.send_on_rejected &&
|
||||||
|
conference.email_settings.rejected_email_template &&
|
||||||
|
conference.email_settings.rejected_subject &&
|
||||||
options[:send_mail].blank?
|
options[:send_mail].blank?
|
||||||
Rails.logger.debug 'Sending rejected mail'
|
Rails.logger.debug 'Sending rejected mail'
|
||||||
Mailbot.rejection_mail(self).deliver
|
Mailbot.rejection_mail(self).deliver
|
||||||
|
|
|
||||||
|
|
@ -23,22 +23,30 @@
|
||||||
%td {eventtitle}
|
%td {eventtitle}
|
||||||
%td The title of an accepted or rejected proposal
|
%td The title of an accepted or rejected proposal
|
||||||
= semantic_form_for(@settings, :url => admin_conference_email_path(@conference.short_title, @conference.email_settings),:html => {:multipart => true}) do |f|
|
= semantic_form_for(@settings, :url => admin_conference_email_path(@conference.short_title, @conference.email_settings),:html => {:multipart => true}) do |f|
|
||||||
= f.input :send_on_registration, :label => false, :hint => "Send an email when the user registers for the conference?"
|
= f.input :send_on_registration, :label => false, :hint => "Send an email when the user registers for the conference?", :input_html => {"data-name"=>"email_settings_registration_subject", "class"=>"send_on_radio"}
|
||||||
= f.input :registration_subject
|
= f.input :registration_subject
|
||||||
= f.input :registration_email_template, :input_html => { :rows => 10, :cols => 20}
|
= f.input :registration_email_template, :input_html => { :rows => 10, :cols => 20}
|
||||||
= f.input :send_on_accepted, :label => false, :hint => "Send an email when the proposal is accepted?"
|
%a.control_label.load_template{"data-template"=>"Dear {name},\n\nThank you for Registering for the conference {conference}.\nPlease complete your registration by filling out your travel information.\n\nIf you are unable to attend please unregister online:\n{registrationlink}\n\nFeel free to contact us with any questions or concerns.\nWe look forward to see you there.\n\nBest wishes\n\n{conference} Team",
|
||||||
|
"data-name"=>"email_settings_registration_email_template"} Load Template
|
||||||
|
= f.input :send_on_accepted, :label => false, :hint => "Send an email when the proposal is accepted?", :input_html => {"data-name"=>"email_settings_accepted_subject", "class"=>"send_on_radio"}
|
||||||
= f.input :accepted_subject
|
= f.input :accepted_subject
|
||||||
= f.input :accepted_email_template, :input_html => { :rows => 10, :cols => 20 }
|
= f.input :accepted_email_template, :input_html => { :rows => 10, :cols => 20 }
|
||||||
= f.input :send_on_rejected, :label => false, :hint => "Send an email when the proposal is rejected?"
|
%a.control_label.load_template{"data-template"=>"Dear {name}\n\nWe are very pleased to inform you that your submission {eventtitle} has been accepted for the conference {conference}.\n\nThe public page of your submission can be found at:\n{proposalslink}\nIf you haven´t already registered for {conference}, please do as soon as possible:\n{registrationlink}\n\nFeel free to contact us with any questions or concerns.\n\nWe look forward to seeing you there.\n\nBest wishes\n\n{conference} Team",
|
||||||
|
"data-name"=>"email_settings_accepted_email_template"} Load Template
|
||||||
|
= f.input :send_on_rejected, :label => false, :hint => "Send an email when the proposal is rejected?", :input_html => {"data-name"=>"email_settings_rejected_subject", "class"=>"send_on_radio"}
|
||||||
= f.input :rejected_subject
|
= f.input :rejected_subject
|
||||||
= f.input :rejected_email_template, :input_html => { :rows => 10, :cols => 20 }
|
= f.input :rejected_email_template, :input_html => { :rows => 10, :cols => 20 }
|
||||||
= f.input :send_on_confirmed_without_registration, :label => false, :hint => "Send an email when a user has a confirmed proposal, but isn't yet registered?"
|
%a.control_label.load_template{"data-template"=>"Dear {name},\n\nThank you for your submission {eventtitle} for the conference {conference}.\nAfter careful consideration we are sorry to inform you that your submissionhas been rejected.\n\n\nBest wishes\n\n{conference} Team",
|
||||||
|
"data-name"=>"email_settings_rejected_email_template"} Load Template
|
||||||
|
= f.input :send_on_confirmed_without_registration, :label => false, :hint => "Send an email when a user has a confirmed proposal, but isn't yet registered?", :input_html => {"data-name"=>"email_settings_confirmed_without_registration_subject", "class"=>"send_on_radio"}
|
||||||
= f.input :confirmed_without_registration_subject
|
= f.input :confirmed_without_registration_subject
|
||||||
= f.input :confirmed_email_template, :input_html => { :rows => 10, :cols => 20 }
|
= f.input :confirmed_email_template, :input_html => { :rows => 10, :cols => 20 }
|
||||||
= f.input :send_on_updated_conference_dates, hint: "This is to notify all participants that the conference dates has been changed."
|
%a.control_label.load_template{"data-template"=>"Dear {name},\n\nThank you for the confirmation of {eventtitle}. Unfortunately you are not registered for the conference {conference}. Please register as soon as possible:\n{registrationlink}\n\nFeel free to contact us with any questions or concerns.\n\nWe look forward to seeing you there.\n\nBest wishes\n\n{conference} Team",
|
||||||
|
"data-name"=>"email_settings_confirmed_email_template"} Load Template
|
||||||
|
= f.input :send_on_updated_conference_dates, hint: "This is to notify all participants that the conference dates has been changed.", :input_html => {"data-name"=>"email_settings_updated_conference_dates_subject", "class"=>"send_on_radio"}
|
||||||
= f.input :updated_conference_dates_subject
|
= f.input :updated_conference_dates_subject
|
||||||
= f.input :updated_conference_dates_template, :input_html => { :rows => 10, :cols => 20 }
|
= f.input :updated_conference_dates_template, :input_html => { :rows => 10, :cols => 20 }
|
||||||
= 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 :send_on_updated_conference_registration_dates, hint: "This is to notify all participants that the conference registration dates has been changed.", :input_html => {"data-name"=>"email_settings_updated_conference_registration_dates_subject", "class"=>"send_on_radio"}
|
||||||
= f.input :updated_conference_registration_dates_subject
|
= f.input :updated_conference_registration_dates_subject
|
||||||
= f.input :updated_conference_registration_dates_template, :input_html => { :rows => 10, :cols => 20 }
|
= f.input :updated_conference_registration_dates_template, :input_html => { :rows => 10, :cols => 20 }
|
||||||
= f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"}
|
= f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
class AddDefaultValueToEmailSettings < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
change_column :email_settings, :send_on_registration, :boolean, default: false
|
||||||
|
change_column :email_settings, :send_on_accepted, :boolean, default: false
|
||||||
|
change_column :email_settings, :send_on_rejected, :boolean, default: false
|
||||||
|
change_column :email_settings, :send_on_confirmed_without_registration, :boolean, default: false
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
change_column :email_settings, :send_on_registration, :boolean, default: true
|
||||||
|
change_column :email_settings, :send_on_accepted, :boolean, default: true
|
||||||
|
change_column :email_settings, :send_on_rejected, :boolean, default: true
|
||||||
|
change_column :email_settings, :send_on_confirmed_without_registration, :boolean, default: true
|
||||||
|
end
|
||||||
|
end
|
||||||
10
db/schema.rb
10
db/schema.rb
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20140714141156) do
|
ActiveRecord::Schema.define(version: 20140716115448) do
|
||||||
|
|
||||||
create_table "ahoy_events", force: true do |t|
|
create_table "ahoy_events", force: true do |t|
|
||||||
t.uuid "visit_id"
|
t.uuid "visit_id"
|
||||||
|
|
@ -150,10 +150,10 @@ ActiveRecord::Schema.define(version: 20140714141156) do
|
||||||
|
|
||||||
create_table "email_settings", force: true do |t|
|
create_table "email_settings", force: true do |t|
|
||||||
t.integer "conference_id"
|
t.integer "conference_id"
|
||||||
t.boolean "send_on_registration", default: true
|
t.boolean "send_on_registration", default: false
|
||||||
t.boolean "send_on_accepted", default: true
|
t.boolean "send_on_accepted", default: false
|
||||||
t.boolean "send_on_rejected", default: true
|
t.boolean "send_on_rejected", default: false
|
||||||
t.boolean "send_on_confirmed_without_registration", default: true
|
t.boolean "send_on_confirmed_without_registration", default: false
|
||||||
t.text "registration_email_template"
|
t.text "registration_email_template"
|
||||||
t.text "accepted_email_template"
|
t.text "accepted_email_template"
|
||||||
t.text "rejected_email_template"
|
t.text "rejected_email_template"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue