refactor(events): replace parties concept with events throughout the application

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

This commit refactors the entire application to replace the 'parties' concept with 'events'. All controllers, models, views, and related files have been updated to reflect this change. The parties table has been replaced with an events table, and all related functionality has been updated accordingly.
This commit is contained in:
Kevin BATAILLE
2025-08-28 13:20:51 +02:00
parent 2f80fe8321
commit 30f3ecc6ad
218 changed files with 864 additions and 787 deletions

View File

@@ -0,0 +1,64 @@
class EventsController < ApplicationController
# Display all events
def index
@events = Event.includes(:user).upcoming.page(params[:page]).per(1)
# @events = Event.page(params[:page]).per(12)
end
# Display desired event
def show
@event = Event.find(params[:id])
end
# Handle checkout process
def checkout
@event = Event.find(params[:id])
cart_data = JSON.parse(params[:cart] || "{}")
if cart_data.empty?
redirect_to event_path(@event), alert: "Please select at least one ticket"
return
end
# Create order items from cart
order_items = []
total_amount = 0
cart_data.each do |ticket_type_id, item|
ticket_type = @event.ticket_types.find_by(id: ticket_type_id)
next unless ticket_type
quantity = item["quantity"].to_i
next if quantity <= 0
# Check availability
available = ticket_type.quantity - ticket_type.tickets.count
if quantity > available
redirect_to event_path(@event), alert: "Not enough tickets available for #{ticket_type.name}"
return
end
order_items << {
ticket_type: ticket_type,
quantity: quantity,
price_cents: ticket_type.price_cents
}
total_amount += ticket_type.price_cents * quantity
end
if order_items.empty?
redirect_to event_path(@event), alert: "Invalid order"
return
end
# Here you would typically:
# 1. Create an Order record
# 2. Create Ticket records for each item
# 3. Redirect to payment processing
# For now, we'll just redirect with a success message
# In a real app, you'd redirect to a payment page
redirect_to event_path(@event), notice: "Order created successfully! Proceeding to payment..."
end
end