temp
This commit is contained in:
parent
3f7f5b6bf4
commit
48a689d452
1 changed files with 36 additions and 13 deletions
|
|
@ -8,25 +8,48 @@ class TicketPurchasesController < ApplicationController
|
||||||
|
|
||||||
def create
|
def create
|
||||||
current_user.ticket_purchases.by_conference(@conference).unpaid.destroy_all
|
current_user.ticket_purchases.by_conference(@conference).unpaid.destroy_all
|
||||||
if current_user.ticket_purchases.by_conference(@conference).paid.any?
|
|
||||||
redirect_to conference_physical_tickets_path,
|
# Create a ticket purchase which can be paid or unpaid
|
||||||
notice: 'You already have tickets for the conference.'
|
|
||||||
end
|
|
||||||
message = TicketPurchase.purchase(@conference, current_user, params[:tickets].try(:first))
|
message = TicketPurchase.purchase(@conference, current_user, params[:tickets].try(:first))
|
||||||
if message.blank?
|
|
||||||
|
# Failed to create ticket purchase
|
||||||
|
if !message.blank?
|
||||||
|
redirect_to conference_tickets_path(@conference.short_title),
|
||||||
|
error: "Oops, something went wrong with your purchase! #{message}"
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
# Ticket purchase created but not paid
|
||||||
if current_user.ticket_purchases.by_conference(@conference).unpaid.any?
|
if current_user.ticket_purchases.by_conference(@conference).unpaid.any?
|
||||||
redirect_to new_conference_payment_path,
|
redirect_to new_conference_payment_path,
|
||||||
notice: 'Please pay here to get tickets.'
|
notice: 'Please pay here to get tickets.'
|
||||||
elsif @conference.tickets.for_registration.any?
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
# TODO: User already paid for a registration ticket and ticket purchase contains one
|
||||||
|
# BUG: When the ticket is free, user will see the notice after they click `Continue`
|
||||||
|
|
||||||
|
# Two types of ticket?
|
||||||
|
|
||||||
|
# TODO: Need to check
|
||||||
|
if current_user.ticket_purchases.by_conference(@conference).paid.any?
|
||||||
|
redirect_to conference_physical_tickets_path,
|
||||||
|
notice: 'You already have tickets for the conference.'
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
# TODO: User wants to purchase a non-registration ticket but does not have a registration ticket but conference requires one
|
||||||
|
# BUG: When the user only purchases a non-registration ticket,
|
||||||
|
if @conference.registration_ticket_required?
|
||||||
redirect_to conference_tickets_path(@conference.short_title),
|
redirect_to conference_tickets_path(@conference.short_title),
|
||||||
error: 'Please get at least one ticket to continue.'
|
error: 'Please get at least one ticket to continue.'
|
||||||
else
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
# TODO: Need to check if the current user didn't a registration ticket and is purchasing one
|
||||||
redirect_to new_conference_conference_registration_path(@conference.short_title)
|
redirect_to new_conference_conference_registration_path(@conference.short_title)
|
||||||
end
|
# # otherwise
|
||||||
else
|
# redirect_to conference_physical_tickets_path
|
||||||
redirect_to conference_tickets_path(@conference.short_title),
|
|
||||||
error: "Oops, something went wrong with your purchase! #{message}"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue