diff --git a/app/controllers/physical_ticket_controller.rb b/app/controllers/physical_ticket_controller.rb index 2354f279..59c248d1 100644 --- a/app/controllers/physical_ticket_controller.rb +++ b/app/controllers/physical_ticket_controller.rb @@ -6,6 +6,7 @@ class PhysicalTicketController < ApplicationController def index @physical_tickets = current_user.physical_tickets.by_conference(@conference) + @unpaid_ticket_purchases = current_user.ticket_purchases.by_conference(@conference).unpaid end def show; end diff --git a/app/controllers/ticket_purchases_controller.rb b/app/controllers/ticket_purchases_controller.rb index 3945e154..792122e2 100644 --- a/app/controllers/ticket_purchases_controller.rb +++ b/app/controllers/ticket_purchases_controller.rb @@ -23,6 +23,10 @@ class TicketPurchasesController < ApplicationController 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/physical_ticket/index.html.haml b/app/views/physical_ticket/index.html.haml index ce741c39..b077400b 100644 --- a/app/views/physical_ticket/index.html.haml +++ b/app/views/physical_ticket/index.html.haml @@ -33,3 +33,10 @@ class: 'button btn btn-default btn-info' - else %h5 No Tickets found! + .row + .col-md-12 + - if @unpaid_ticket_purchases.any? + .h3 + You have unpaid tickets! + %small + = link_to "Pay them here", conference_ticket_purchases_path diff --git a/app/views/ticket_purchases/index.html.haml b/app/views/ticket_purchases/index.html.haml new file mode 100644 index 00000000..c9255c37 --- /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 ae67a820..db88613f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -125,7 +125,7 @@ Osem::Application.routes.draw do # 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]