Browse Source

Fixed user mailer when ids are nil

development
Godwin 8 years ago
committed by GitHub
parent
commit
44e66e9167
  1. 36
      app/mailers/user_mailer.rb

36
app/mailers/user_mailer.rb

@ -9,13 +9,13 @@ class UserMailer < ActionMailer::Base
default from: "Bike!Bike! <noreply@bikebike.org>" default from: "Bike!Bike! <noreply@bikebike.org>"
def email_confirmation(confirmation) def email_confirmation(confirmation)
@confirmation = EmailConfirmation.find(confirmation) @confirmation = EmailConfirmation.find(confirmation) if confirmation.present?
@subject = _'email.subject.confirm_email','Please confirm your email address' @subject = _'email.subject.confirm_email','Please confirm your email address'
mail to: @confirmation.user.named_email, subject: @subject mail to: @confirmation.user.named_email, subject: @subject
end end
def registration_confirmation(registration) def registration_confirmation(registration)
@registration = ConferenceRegistration.find(registration) @registration = ConferenceRegistration.find(registration) if registration.present?
@conference = @registration.conference @conference = @registration.conference
@user = @registration.user @user = @registration.user
@subject = @conference.registration_status.to_sym == :pre ? @subject = @conference.registration_status.to_sym == :pre ?
@ -35,7 +35,7 @@ class UserMailer < ActionMailer::Base
@host = host @host = host
@content = content @content = content
@banner = nil @banner = nil
@conference = Conference.find(conference) @conference = Conference.find(conference) if conference.present?
@user = Conference.find(user) if user.present? @user = Conference.find(user) if user.present?
@subject = "[#{conference ? conference.title : 'Bike!Bike!'}] #{subject}" @subject = "[#{conference ? conference.title : 'Bike!Bike!'}] #{subject}"
if @user && @user.named_email if @user && @user.named_email
@ -44,8 +44,8 @@ class UserMailer < ActionMailer::Base
end end
def workshop_facilitator_request(workshop, requester, message) def workshop_facilitator_request(workshop, requester, message)
@workshop = Workshop.find(workshop) @workshop = Workshop.find(workshop) if workshop.present?
@requester = User.find(requester) @requester = User.find(requester) if requester.present?
addresses = [] addresses = []
@workshop.active_facilitators.each do |f| @workshop.active_facilitators.each do |f|
addresses << f.named_email addresses << f.named_email
@ -59,9 +59,9 @@ class UserMailer < ActionMailer::Base
end end
def workshop_facilitator_request_approved(workshop, user) def workshop_facilitator_request_approved(workshop, user)
@workshop = Workshop.find(workshop) @workshop = Workshop.find(workshop) if workshop.present?
@conference = Conference.find(@workshop.conference_id) @conference = Conference.find(@workshop.conference_id)
@user = User.find(user) @user = User.find(user) if user.present?
@subject = (_'email.subject.workshop_request_approved', @subject = (_'email.subject.workshop_request_approved',
"You have been added as a facilitator of #{@workshop.title}", "You have been added as a facilitator of #{@workshop.title}",
:vars => {:workshop_title => @workshop.title}) :vars => {:workshop_title => @workshop.title})
@ -69,9 +69,9 @@ class UserMailer < ActionMailer::Base
end end
def workshop_facilitator_request_denied(workshop, user) def workshop_facilitator_request_denied(workshop, user)
@workshop = Workshop.find(workshop) @workshop = Workshop.find(workshop) if workshop.present?
@conference = @workshop.conference @conference = @workshop.conference
@user = User.find(user) @user = User.find(user) if user.present?
@subject = (_'email.subject.workshop_request_denied', @subject = (_'email.subject.workshop_request_denied',
"Your request to facilitate #{@workshop.title} has been denied", "Your request to facilitate #{@workshop.title} has been denied",
:vars => {:workshop_title => @workshop.title}) :vars => {:workshop_title => @workshop.title})
@ -79,12 +79,12 @@ class UserMailer < ActionMailer::Base
end end
def workshop_translated(workshop, data, locale, user, translator) def workshop_translated(workshop, data, locale, user, translator)
@workshop = Workshop.find(workshop) @workshop = Workshop.find(workshop) if workshop.present?
@data = data @data = data
@locale = locale @locale = locale
@locale_name = language_name(locale) @locale_name = language_name(locale)
@user = User.find(user) @user = User.find(user) if user.present?
@translator = User.find(translator) @translator = User.find(translator) if translator.present?
@subject = (_'email.subject.workshop_translated', @subject = (_'email.subject.workshop_translated',
"The #{@locale_name} translation for #{@workshop.title} has been modified", "The #{@locale_name} translation for #{@workshop.title} has been modified",
vars: {language: @language_name, workshop_title: @workshop.title}) vars: {language: @language_name, workshop_title: @workshop.title})
@ -102,10 +102,10 @@ class UserMailer < ActionMailer::Base
end end
def workshop_original_content_changed(workshop, data, user, translator) def workshop_original_content_changed(workshop, data, user, translator)
@workshop = Workshop.find(workshop) @workshop = Workshop.find(workshop) if workshop.present?
@data = data @data = data
@user = User.find(user) @user = User.find(user) if user.present?
@translator = User.find(translator) @translator = User.find(translator) if translator.present?
@subject = (_'email.subject.workshop_original_content_changed', @subject = (_'email.subject.workshop_original_content_changed',
"Original content for #{@workshop.title} has been modified", "Original content for #{@workshop.title} has been modified",
vars: {workshop_title: @workshop.title}) vars: {workshop_title: @workshop.title})
@ -123,9 +123,9 @@ class UserMailer < ActionMailer::Base
end end
def workshop_comment(workshop, comment, user) def workshop_comment(workshop, comment, user)
@workshop = Workshop.find(workshop) @workshop = Workshop.find(workshop) if workshop.present?
@comment = comment @comment = comment
@user = User.find(user) @user = User.find(user) if user.present?
if comment.reply? if comment.reply?
@subject = (_'email.subject.workshop_comment.reply', vars: { user_name: comment.user.name }) @subject = (_'email.subject.workshop_comment.reply', vars: { user_name: comment.user.name })
@ -143,7 +143,7 @@ class UserMailer < ActionMailer::Base
@exception = exception @exception = exception
@request = request @request = request
@params = params @params = params
@user = User.find(user) @user = User.find(user) if user.present?
mail to: 'goodgodwin@hotmail.com', subject: @subject mail to: 'goodgodwin@hotmail.com', subject: @subject
end end

Loading…
Cancel
Save