2018-05-07 16:47:29 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2017-09-26 21:43:18 +05:30
|
|
|
class PhysicalTicketsController < ApplicationController
|
2017-06-03 16:05:59 +05:30
|
|
|
before_action :authenticate_user!
|
|
|
|
|
load_resource :conference, find_by: :short_title
|
2017-07-10 20:43:27 +05:30
|
|
|
load_and_authorize_resource find_by: :token
|
2017-06-03 16:05:59 +05:30
|
|
|
authorize_resource :conference_registrations, class: Registration
|
|
|
|
|
|
|
|
|
|
def index
|
|
|
|
|
@physical_tickets = current_user.physical_tickets.by_conference(@conference)
|
2017-06-26 06:07:52 +05:30
|
|
|
@unpaid_ticket_purchases = current_user.ticket_purchases.by_conference(@conference).unpaid
|
2017-06-03 16:05:59 +05:30
|
|
|
end
|
|
|
|
|
|
2017-06-13 07:20:43 +05:30
|
|
|
def show
|
2018-01-16 15:22:15 +13:00
|
|
|
@file_name = "ticket_for_#{@conference.short_title}.pdf"
|
2017-06-13 07:20:43 +05:30
|
|
|
@user = @physical_ticket.user
|
2017-06-30 05:26:21 +05:30
|
|
|
@ticket_layout = @conference.ticket_layout.to_sym
|
2017-07-27 17:25:17 +05:30
|
|
|
@qrcode_image = RQRCode::QRCode.new(@physical_ticket.token).as_png(size: 180, border_modules: 0)
|
2017-07-15 03:37:32 +05:30
|
|
|
respond_to do |format|
|
|
|
|
|
format.html
|
|
|
|
|
format.pdf do
|
|
|
|
|
pdf = TicketPdf.new(@conference, @user, @physical_ticket, @ticket_layout, @file_name)
|
|
|
|
|
send_data pdf.render,
|
|
|
|
|
filename: @file_name,
|
|
|
|
|
type: 'application/pdf',
|
|
|
|
|
disposition: 'attachment'
|
|
|
|
|
end
|
|
|
|
|
end
|
2017-06-13 07:20:43 +05:30
|
|
|
end
|
2017-06-03 16:05:59 +05:30
|
|
|
end
|