diff --git a/app/controllers/admin/registrations_controller.rb b/app/controllers/admin/registrations_controller.rb index 2afb8f6a..4d17ee38 100644 --- a/app/controllers/admin/registrations_controller.rb +++ b/app/controllers/admin/registrations_controller.rb @@ -30,6 +30,13 @@ module Admin end end + def show + @file_name = "ticket_for_#{@conference.short_title}" + respond_to do |format| + format.pdf {} + end + end + def destroy if can? :destroy, @registration @registration.destroy diff --git a/app/controllers/conference_registrations_controller.rb b/app/controllers/conference_registrations_controller.rb index c229440e..44a2bde8 100644 --- a/app/controllers/conference_registrations_controller.rb +++ b/app/controllers/conference_registrations_controller.rb @@ -31,6 +31,11 @@ class ConferenceRegistrationsController < ApplicationController @tickets = current_user.ticket_purchases.by_conference(@conference).paid @ticket_payments = @tickets.group_by(&:ticket_id) @total_quantity = @tickets.group(:ticket_id).sum(:quantity) + @file_name = "ticket_for_#{@conference.short_title}" + respond_to do |format| + format.html + format.pdf {} + end end def edit; end diff --git a/app/views/admin/registrations/index.html.haml b/app/views/admin/registrations/index.html.haml index a51d41fc..32e8e14b 100644 --- a/app/views/admin/registrations/index.html.haml +++ b/app/views/admin/registrations/index.html.haml @@ -70,6 +70,7 @@ method: :get, class: 'btn btn-primary' = link_to 'Delete', admin_conference_registration_path(@conference.short_title, registration), method: :delete, class: 'btn btn-danger', data: { confirm: "Do you really want to delete the Registration for #{registration.name}?" } + = link_to 'Export Ticket', admin_conference_registration_path(@conference.short_title, registration, format: :pdf), class: 'btn btn-success' - @registrations.each_with_index do |registration, index| .questions{class: "question#{index}", style: 'display:none;'} = render partial: 'questions', locals: { registration: registration } diff --git a/app/views/admin/registrations/show.pdf.prawn b/app/views/admin/registrations/show.pdf.prawn new file mode 100644 index 00000000..8268ff1d --- /dev/null +++ b/app/views/admin/registrations/show.pdf.prawn @@ -0,0 +1,2 @@ +prawn_document(force_download: true, filename: "#{@file_name}.pdf", page_layout: :landscape) do |pdf| +end diff --git a/app/views/conference_registrations/show.html.haml b/app/views/conference_registrations/show.html.haml index c510a263..de98356f 100644 --- a/app/views/conference_registrations/show.html.haml +++ b/app/views/conference_registrations/show.html.haml @@ -104,6 +104,7 @@ = humanized_money tickets.first.price %br - if @tickets.any? + = link_to 'Download Ticket', conference_conference_registration_path(@conference.short_title, format: :pdf), class: 'button btn btn-default btn-info' = link_to 'Get more tickets', conference_tickets_path(@conference.short_title), class: "btn btn-default" - else You haven't bought any tickets. diff --git a/app/views/conference_registrations/show.pdf.prawn b/app/views/conference_registrations/show.pdf.prawn new file mode 100644 index 00000000..8268ff1d --- /dev/null +++ b/app/views/conference_registrations/show.pdf.prawn @@ -0,0 +1,2 @@ +prawn_document(force_download: true, filename: "#{@file_name}.pdf", page_layout: :landscape) do |pdf| +end