develop #3

Merged
kbe merged 227 commits from develop into main 2025-09-16 14:35:23 +00:00
2 changed files with 11 additions and 5 deletions
Showing only changes of commit 7009245ab0 - Show all commits

View File

@@ -3,7 +3,7 @@
# This controller now primarily handles legacy redirects and backward compatibility
# Most ticket creation functionality has been moved to OrdersController
class TicketsController < ApplicationController
before_action :authenticate_user!, only: [ :payment_success, :payment_cancel ]
before_action :authenticate_user!, only: [ :payment_success, :payment_cancel, :show, :download_ticket ]
before_action :set_event, only: [ :checkout, :retry_payment ]
@@ -49,7 +49,10 @@ class TicketsController < ApplicationController
end
def show
@ticket = current_user.orders.joins(:tickets).find(params[:ticket_id])
@ticket = Ticket.joins(order: :user).includes(:event, :ticket_type, order: :user).find_by(
tickets: { id: params[:ticket_id] },
orders: { user_id: current_user.id }
)
@event = @ticket.event
rescue ActiveRecord::RecordNotFound
redirect_to dashboard_path, alert: "Billet non trouvé"
@@ -58,7 +61,10 @@ class TicketsController < ApplicationController
# Download PDF ticket - only accessible by ticket owner
def download_ticket
# Find ticket and ensure it belongs to current user
@ticket = current_user.orders.joins(:tickets).find_by(tickets: { id: params[:ticket_id] })
@ticket = Ticket.joins(order: :user).includes(:event, :ticket_type, order: :user).find_by(
tickets: { id: params[:ticket_id] },
orders: { user_id: current_user.id }
)
if @ticket.nil?
redirect_to dashboard_path, alert: "Billet non trouvé ou vous n'avez pas l'autorisation d'accéder à ce billet"

View File

@@ -91,8 +91,8 @@ class TicketPdfGenerator
raise "QR code data is empty or invalid"
end
qrcode = RQRCode::QRCode.new(qr_code_data)
pdf.print_qr_code(qrcode, extent: 120, align: :center)
# Generate QR code - prawn-qrcode expects the data string directly
pdf.print_qr_code(qr_code_data, extent: 120, align: :center)
pdf.move_down 15