diff --git a/app/controllers/ticket_purchases_controller.rb b/app/controllers/ticket_purchases_controller.rb index 3945e15461..ac3200312c 100644 --- a/app/controllers/ticket_purchases_controller.rb +++ b/app/controllers/ticket_purchases_controller.rb @@ -6,6 +6,7 @@ class TicketPurchasesController < ApplicationController def create current_user.ticket_purchases.by_conference(@conference).unpaid.destroy_all message = TicketPurchase.purchase(@conference, current_user, params[:tickets][0]) + if message.blank? if current_user.ticket_purchases.by_conference(@conference).unpaid.any? redirect_to new_conference_payment_path, @@ -23,6 +24,10 @@ def create end end + def index + @unpaid_ticket_purchases = current_user.ticket_purchases.by_conference(@conference).unpaid + end + private def ticket_purchase_params diff --git a/app/views/conferences/_conference_details.html.haml b/app/views/conferences/_conference_details.html.haml index d5bafad483..7b8f516d4d 100644 --- a/app/views/conferences/_conference_details.html.haml +++ b/app/views/conferences/_conference_details.html.haml @@ -34,6 +34,8 @@ = link_to "My Proposals", conference_program_proposals_path(conference.short_title), class: 'btn btn-default' - elsif can? :new, conference.program.events.new = link_to "Submit Proposal", new_conference_program_proposal_path(conference.short_title), class: 'btn btn-default' + - if current_user && current_user.ticket_purchases.by_conference(conference).unpaid.any? + = link_to "Ticket Purchases", conference_ticket_purchases_path(conference.short_title), class: 'btn btn-default' - if current_user.nil? || !current_user.subscribed?(conference) = link_to 'Subscribe', conference_subscriptions_path(conference.short_title), method: :post, class: 'btn btn-default' - else diff --git a/app/views/ticket_purchases/index.html.haml b/app/views/ticket_purchases/index.html.haml new file mode 100644 index 0000000000..c9255c37bf --- /dev/null +++ b/app/views/ticket_purchases/index.html.haml @@ -0,0 +1,30 @@ +.container + .row + .col-md-12.page-header + %h2 + Ticket Purchases + .text-muted + Your unpaid ticket purchases for the conference + + .col-md-12 + - if @unpaid_ticket_purchases.present? + %table.table.table-bordered.table-striped.table-hover#roles + %thead + %th ID + %th Type + %th Quantity + %th Date + %th Actions + %tbody + - @unpaid_ticket_purchases.each do |ticket_purchase| + %tr + %td= ticket_purchase.id + %td= ticket_purchase.ticket.title + %td= ticket_purchase.quantity + %td= ticket_purchase.created_at.strftime('%B %d, %Y') + %td + .btn-group + = link_to 'Pay', new_conference_payment_path, + class: 'btn btn-primary' + - else + %h5 You don't have any unpaid ticket purchase! diff --git a/config/routes.rb b/config/routes.rb index 8fa4b85758..41fdab991a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -124,7 +124,7 @@ # TODO: change conference_registrations to singular resource resource :conference_registration, path: 'register' resources :tickets, only: [:index] - resources :ticket_purchases, only: [:create, :destroy] + resources :ticket_purchases, only: [:create, :destroy, :index] resources :payments, only: [:index, :new, :create] resources :physical_ticket, only: [:index, :show] resource :subscriptions, only: [:create, :destroy]