Merge pull request #1600 from siddhantbajaj/pdf-attachment

Send mail on ticket confirmation with attached ticket pdf.
This commit is contained in:
Ana María Martínez Gómez 2017-07-26 09:39:11 +02:00 committed by GitHub
commit edd0024a17
3 changed files with 25 additions and 0 deletions

View file

@ -8,6 +8,22 @@ class Mailbot < ActionMailer::Base
conference.email_settings.registration_body))
end
def ticket_confirmation_mail(ticket_purchase)
@ticket_purchase = ticket_purchase
@conference = ticket_purchase.conference
@user = ticket_purchase.user
PhysicalTicket.last(ticket_purchase.quantity).each do |physical_ticket|
pdf = TicketPdf.new(@conference, @user, physical_ticket, @conference.ticket_layout.to_sym, "ticket_for_#{@conference.short_title}_#{physical_ticket.id}")
attachments["ticket_for_#{@conference.short_title}_#{physical_ticket.id}"] = pdf.render
end
mail(to: @user.email,
from: @conference.contact.email,
template_name: 'ticket_confirmation_template',
subject: "#{@conference.title} | Ticket Confirmation and PDF!")
end
def acceptance_mail(event)
conference = event.program.conference

View file

@ -69,6 +69,7 @@ class TicketPurchase < ActiveRecord::Base
PhysicalTicket.transaction do
quantity.times { physical_tickets.create }
end
Mailbot.ticket_confirmation_mail(self).deliver_later
end
end

View file

@ -0,0 +1,8 @@
Dear <%= @user.name %>,
Thanks! You have successfully booked <%= @ticket_purchase.quantity %> <%= @ticket_purchase.ticket.title %> ticket(s) for the event <%= @conference.title %>. Your transaction id is <%= @ticket_purchase.id %>.
Please, find the ticket(s) pdf attached.
Best wishes,
<%= @conference.title %> Team