Merge pull request #1600 from siddhantbajaj/pdf-attachment
Send mail on ticket confirmation with attached ticket pdf.
This commit is contained in:
commit
edd0024a17
3 changed files with 25 additions and 0 deletions
|
|
@ -8,6 +8,22 @@ class Mailbot < ActionMailer::Base
|
||||||
conference.email_settings.registration_body))
|
conference.email_settings.registration_body))
|
||||||
end
|
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)
|
def acceptance_mail(event)
|
||||||
conference = event.program.conference
|
conference = event.program.conference
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ class TicketPurchase < ActiveRecord::Base
|
||||||
PhysicalTicket.transaction do
|
PhysicalTicket.transaction do
|
||||||
quantity.times { physical_tickets.create }
|
quantity.times { physical_tickets.create }
|
||||||
end
|
end
|
||||||
|
Mailbot.ticket_confirmation_mail(self).deliver_later
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
8
app/views/mailbot/ticket_confirmation_template.text.erb
Normal file
8
app/views/mailbot/ticket_confirmation_template.text.erb
Normal 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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue