From 05392701a981f87af3cb756cd20c49e10bc79837 Mon Sep 17 00:00:00 2001 From: Chrisbr Date: Tue, 13 May 2014 14:50:29 +0200 Subject: [PATCH 1/4] Send registration mail only if email settings true --- app/controllers/conference_registration_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/conference_registration_controller.rb b/app/controllers/conference_registration_controller.rb index 5df877e2..21928fb4 100644 --- a/app/controllers/conference_registration_controller.rb +++ b/app/controllers/conference_registration_controller.rb @@ -74,7 +74,9 @@ class ConferenceRegistrationController < ApplicationController if update_registration redirect_message = "Registration updated." else - Mailbot.registration_mail(conference, current_user.person).deliver + if conference.email_settings.send_on_registration? + Mailbot.registration_mail(conference, current_user.person).deliver + end end redirect_to(register_conference_path(:id => conference.short_title), :notice => redirect_message) end From 0db2f3bb061e6af3cf31bba54e98a097e9c51116 Mon Sep 17 00:00:00 2001 From: Chrisbr Date: Tue, 13 May 2014 15:24:21 +0200 Subject: [PATCH 2/4] Bugfix send accept / reject event mail --- app/models/event.rb | 9 +++++---- app/views/admin/events/index.html.haml | 28 +++++++++++++------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/app/models/event.rb b/app/models/event.rb index 23e903c9..42411e9f 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -132,14 +132,15 @@ class Event < ActiveRecord::Base end def process_acceptance(options) - if options[:send_mail] == "true" - Rails.logger.debug "Sending acceptance mail" - Mailbot.acceptance_mail(self).deliver + if self.conference.email_settings.send_on_accepted && options[:send_mail].blank? + Rails.logger.debug 'Sending event acceptance mail' + Mailbot.acceptance_mail(self).deliver end end def process_rejection(options) - if options[:send_mail] == "true" + if self.conference.email_settings.send_on_rejected && options[:send_mail].blank? + Rails.logger.debug 'Sending rejected mail' Mailbot.rejection_mail(self).deliver end end diff --git a/app/views/admin/events/index.html.haml b/app/views/admin/events/index.html.haml index 6b608947..bd6eae05 100644 --- a/app/views/admin/events/index.html.haml +++ b/app/views/admin/events/index.html.haml @@ -106,21 +106,21 @@ %ul.dropdown-menu - if event.transition_possible? :accept - %li= link_to 'Accept event (no email)', - update_state_admin_conference_event_path(@conference.short_title, event, transition: :accept, send_mail: false), - method: :patch, hint: 'Accept this event without sending an automated email.' - %li= link_to 'Accept event (WITH email)', - update_state_admin_conference_event_path(@conference.short_title, event, transition: :accept, send_mail: true), - method: :patch, hint: 'Accept this event and send an automated email.' + %li= link_to 'Accept event', + update_state_admin_conference_event_path(@conference.short_title, event, transition: :accept), + method: :patch + - if @conference.email_settings.send_on_accepted? + %li= link_to 'Accept event (without email)', + update_state_admin_conference_event_path(@conference.short_title, event, transition: :accept, send_mail: false), + method: :patch, hint: 'Accept this event without sending an automated email.' - if event.transition_possible? :reject - %li= link_to 'Reject event (no email)', - update_state_admin_conference_event_path(@conference.short_title, event, transition: :reject, send_mail: false), - method: :patch, confirm: 'Are you sure?', - hint: 'Reject this event without sending an automated email.' - %li= link_to 'Reject event (WITH email)', - update_state_admin_conference_event_path(@conference.short_title, event, transition: :reject, send_mail: true), - method: :patch, confirm: 'Are you sure?', - hint: 'Reject this event and send an automated email.' + %li= link_to 'Reject event', + update_state_admin_conference_event_path(@conference.short_title, event, transition: :reject), + method: :patch, confirm: 'Are you sure?' + - if @conference.email_settings.send_on_rejected? + %li= link_to 'Reject event (without email)', + update_state_admin_conference_event_path(@conference.short_title, event, transition: :reject, send_mail: false), + method: :patch, confirm: 'Are you sure?' - if event.transition_possible? :start_review %li= link_to 'Start review', update_state_admin_conference_event_path(@conference.short_title, event, transition: :start_review), From 37430152c6f1e5565e56c91d2658a17769e6abee Mon Sep 17 00:00:00 2001 From: Chrisbr Date: Tue, 13 May 2014 15:27:43 +0200 Subject: [PATCH 3/4] fix Hound CI violations --- app/models/event.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/models/event.rb b/app/models/event.rb index 42411e9f..78d7e5d4 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -132,14 +132,16 @@ class Event < ActiveRecord::Base end def process_acceptance(options) - if self.conference.email_settings.send_on_accepted && options[:send_mail].blank? - Rails.logger.debug 'Sending event acceptance mail' - Mailbot.acceptance_mail(self).deliver + if self.conference.email_settings.send_on_accepted && + options[:send_mail].blank? + Rails.logger.debug 'Sending event acceptance mail' + Mailbot.acceptance_mail(self).deliver end end def process_rejection(options) - if self.conference.email_settings.send_on_rejected && options[:send_mail].blank? + if self.conference.email_settings.send_on_rejected && + options[:send_mail].blank? Rails.logger.debug 'Sending rejected mail' Mailbot.rejection_mail(self).deliver end From c7e5c732420128938835cd15a872589b510601ba Mon Sep 17 00:00:00 2001 From: Chrisbr Date: Tue, 13 May 2014 15:28:25 +0200 Subject: [PATCH 4/4] removes redundant self --- app/models/event.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/event.rb b/app/models/event.rb index 78d7e5d4..f40c86b4 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -132,7 +132,7 @@ class Event < ActiveRecord::Base end def process_acceptance(options) - if self.conference.email_settings.send_on_accepted && + if conference.email_settings.send_on_accepted && options[:send_mail].blank? Rails.logger.debug 'Sending event acceptance mail' Mailbot.acceptance_mail(self).deliver @@ -140,7 +140,7 @@ class Event < ActiveRecord::Base end def process_rejection(options) - if self.conference.email_settings.send_on_rejected && + if conference.email_settings.send_on_rejected && options[:send_mail].blank? Rails.logger.debug 'Sending rejected mail' Mailbot.rejection_mail(self).deliver