Skip to content

Commit

Permalink
Merge 5f4760a into f37d309
Browse files Browse the repository at this point in the history
  • Loading branch information
siddhantbajaj committed Jun 27, 2017
2 parents f37d309 + 5f4760a commit a0895d3
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/controllers/ticket_purchases_controller.rb
Expand Up @@ -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,
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions app/views/conferences/_conference_details.html.haml
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions 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!
2 changes: 1 addition & 1 deletion config/routes.rb
Expand Up @@ -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]
Expand Down

0 comments on commit a0895d3

Please sign in to comment.