Introduced Physical Ticket

Added PhysicalTicket model and controller. It holds the information about each physical ticket bought at the purchase. Physical Tickets are created after every successfull payment.
This commit is contained in:
Siddhant Bajaj 2017-06-03 16:05:59 +05:30 committed by siddhantbajaj
parent 1c38b091cc
commit 5c56683ae8
17 changed files with 115 additions and 12 deletions

View file

@ -18,7 +18,7 @@ class PaymentsController < ApplicationController
if @payment.purchase && @payment.save
update_purchased_ticket_purchases
redirect_to conference_conference_registration_path(@conference.short_title),
redirect_to conference_physical_ticket_index_path,
notice: 'Thanks! Your ticket is booked successfully.'
else
@total_amount_to_pay = Ticket.total_price(@conference, current_user, paid: false)
@ -38,6 +38,8 @@ class PaymentsController < ApplicationController
end
def update_purchased_ticket_purchases
current_user.ticket_purchases.by_conference(@conference).unpaid.update_all(paid: true, payment_id: @payment.id)
current_user.ticket_purchases.by_conference(@conference).unpaid.each do |ticket_purchase|
ticket_purchase.pay(@payment)
end
end
end