Fix email notifications
This commit is contained in:
parent
2e79f65989
commit
14011f8828
9 changed files with 43 additions and 28 deletions
|
|
@ -514,10 +514,11 @@ class Conference < ActiveRecord::Base
|
|||
# * +True+ -> If conference is updated and all other parameters are set
|
||||
# * +False+ -> Either conference is not updated or one or more parameter is not set
|
||||
def notify_on_dates_changed?
|
||||
(self.start_date_changed? || self.end_date_changed?) &&
|
||||
self.email_settings.send_on_conference_dates_updated &&
|
||||
!self.email_settings.conference_dates_updated_subject.blank? &&
|
||||
self.email_settings.conference_dates_updated_body
|
||||
return false unless self.email_settings.send_on_conference_dates_updated
|
||||
# do not notify unless one of the dates changed
|
||||
return false unless self.start_date_changed? || self.end_date_changed?
|
||||
# do not notify unless the mail content is set up
|
||||
(!email_settings.conference_dates_updated_subject.blank? && !email_settings.conference_dates_updated_body.blank?)
|
||||
end
|
||||
|
||||
##
|
||||
|
|
@ -527,11 +528,13 @@ class Conference < ActiveRecord::Base
|
|||
# * +True+ -> If registration dates is updated and all other parameters are set
|
||||
# * +False+ -> Either registration date is not updated or one or more parameter is not set
|
||||
def notify_on_registration_dates_changed?
|
||||
registration_period &&
|
||||
(registration_period.start_date_changed? || registration_period.end_date_changed?) &&
|
||||
email_settings.send_on_conference_registration_dates_updated &&
|
||||
!email_settings.conference_registration_dates_updated_subject.blank? &&
|
||||
email_settings.conference_registration_dates_updated_body
|
||||
return false unless self.email_settings.send_on_conference_registration_dates_updated
|
||||
# do not notify unless we allow a registration
|
||||
return false unless self.registration_period
|
||||
# do not notify unless one of the dates changed
|
||||
return false unless registration_period.start_date_changed? || registration_period.end_date_changed?
|
||||
# do not notify unless the mail content is set up
|
||||
(!email_settings.conference_registration_dates_updated_subject.blank? && !email_settings.conference_registration_dates_updated_body.blank?)
|
||||
end
|
||||
|
||||
def registration_limit_exceeded?
|
||||
|
|
|
|||
|
|
@ -122,7 +122,6 @@ class Event < ActiveRecord::Base
|
|||
program.conference.email_settings.accepted_body &&
|
||||
program.conference.email_settings.accepted_subject &&
|
||||
!options[:send_mail].blank?
|
||||
Rails.logger.debug 'Sending event acceptance mail'
|
||||
Mailbot.delay.acceptance_mail(self)
|
||||
end
|
||||
end
|
||||
|
|
@ -132,7 +131,6 @@ class Event < ActiveRecord::Base
|
|||
program.conference.email_settings.rejected_body &&
|
||||
program.conference.email_settings.rejected_subject &&
|
||||
!options[:send_mail].blank?
|
||||
Rails.logger.debug 'Sending rejected mail'
|
||||
Mailbot.delay.rejection_mail(self)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -64,6 +64,14 @@ class Program < ActiveRecord::Base
|
|||
cfp.present? && (cfp.start_date..cfp.end_date).cover?(Date.current)
|
||||
end
|
||||
|
||||
def notify_on_schedule_public?
|
||||
return false unless conference.email_settings.send_on_program_schedule_public
|
||||
# do not notify if the schedule is not public
|
||||
return false unless schedule_public
|
||||
# do not notify unless the mail content is set up
|
||||
(!conference.email_settings.program_schedule_public_subject.blank? && !conference.email_settings.program_schedule_public_body.blank?)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
##
|
||||
|
|
|
|||
|
|
@ -30,15 +30,15 @@ class Venue < ActiveRecord::Base
|
|||
private
|
||||
|
||||
def send_mail_notification
|
||||
Mailbot.delay.send_email_on_venue_updated(conference) if venue_notify?(conference)
|
||||
Mailbot.delay.send_email_on_venue_updated(conference) if notify_on_venue_changed?
|
||||
end
|
||||
|
||||
def venue_notify?(conference)
|
||||
(self.name_changed? || self.street_changed?) &&
|
||||
(!self.name.blank? && !self.street.blank?) &&
|
||||
(conference.email_settings.send_on_venue_updated &&
|
||||
!conference.email_settings.venue_updated_subject.blank? &&
|
||||
conference.email_settings.venue_updated_body)
|
||||
def notify_on_venue_changed?
|
||||
return false unless conference.email_settings.send_on_venue_updated
|
||||
# do not notify unless the address changed
|
||||
return false unless self.name_changed? || self.street_changed? || self.city_changed? || self.country_changed?
|
||||
# do not notify unless the mail content is set up
|
||||
(!conference.email_settings.venue_updated_subject.blank? && !conference.email_settings.venue_updated_body.blank?)
|
||||
end
|
||||
|
||||
# TODO: create a module to be mixed into model to perform same operation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue