wip: OrdersController#new
This commit is contained in:
@@ -6,7 +6,31 @@ class OrdersController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
before_action :set_order, only: [:show, :checkout, :retry_payment, :increment_payment_attempt]
|
||||
|
||||
# Display new order form
|
||||
#
|
||||
# On this page user can complete the tickets details (first name and last name),
|
||||
# add a comment on the order.
|
||||
def new
|
||||
@cart_data = session[:pending_cart] || {}
|
||||
|
||||
if @cart_data.empty?
|
||||
redirect_to root_path, alert: "Veuillez d'abord sélectionner vos billets"
|
||||
return
|
||||
end
|
||||
|
||||
# Build order preview from cart data
|
||||
@event_id = session[:event_id]
|
||||
if @event_id.present?
|
||||
@event = Event.includes(:ticket_types).find_by(id: @event_id)
|
||||
redirect_to root_path, alert: "Événement non trouvé" unless @event
|
||||
else
|
||||
redirect_to root_path, alert: "Informations manquantes"
|
||||
end
|
||||
end
|
||||
|
||||
# Display order summary
|
||||
#
|
||||
#
|
||||
def show
|
||||
@tickets = @order.tickets.includes(:ticket_type)
|
||||
end
|
||||
@@ -115,7 +139,7 @@ class OrdersController < ApplicationController
|
||||
|
||||
if order_id.present?
|
||||
order = current_user.orders.find_by(id: order_id, status: "draft")
|
||||
|
||||
|
||||
if order&.can_retry_payment?
|
||||
redirect_to order_checkout_path(order),
|
||||
alert: "Le paiement a été annulé. Vous pouvez réessayer."
|
||||
@@ -163,4 +187,4 @@ class OrdersController < ApplicationController
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user