Enhanced TicketType model with helper methods and better validations So the full context is: ## Backend Implementation - Enhanced TicketType model with helper methods and better validations - New Promoter::TicketTypesController with full authorization - Sales status tracking (draft, available, upcoming, expired, sold_out) - New Promoter::TicketTypesController with full authorization - Safe calculation methods preventing nil value errors - Sales status tracking (draft, available, upcoming, expired, sold_out) ## Frontend Features - Modern responsive UI with Tailwind CSS styling - Interactive forms with Stimulus controller for dynamic calculations - Revenue calculators showing potential, current, and remaining revenue - Status indicators with appropriate colors and icons - Buyer analytics and purchase history display ## JavaScript Enhancements - New TicketTypeFormController for dynamic pricing calculations - Real-time total updates as users type price/quantity - Proper French currency formatting - Form validation for minimum quantities based on existing sales ## Bug Fixes Fixed nil value errors in price_euros method when price_cents is nil Added defensive programming for all calculation methods Graceful handling of incomplete ticket types during creation Proper default values for new ticket type instances ## Files Added/Modified - app/controllers/promoter/ticket_types_controller.rb (new) - app/javascript/controllers/ticket_type_form_controller.js (new) - app/views/promoter/ticket_types/*.html.erb (4 new view files) - app/models/ticket_type.rb (enhanced with helper methods) - config/routes.rb (added nested ticket_types routes) - db/migrate/*_add_requires_id_to_ticket_types.rb (new migration) ## Integration - Seamless integration with existing event management system - Updated promoter event show page with ticket management link - Proper scoping ensuring promoters only manage their own tickets - Compatible with existing ticket purchasing and checkout flow
86 lines
3.2 KiB
Ruby
Executable File
86 lines
3.2 KiB
Ruby
Executable File
Rails.application.routes.draw do
|
|
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
|
|
|
|
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
|
|
# Can be used by load balancers and uptime monitors to verify that the app is live.
|
|
get "up" => "rails/health#show", as: :rails_health_check
|
|
|
|
# Render dynamic PWA files from app/views/pwa/* (remember to link manifest in application.html.erb)
|
|
# get "manifest" => "rails/pwa#manifest", as: :pwa_manifest
|
|
# get "service-worker" => "rails/pwa#service_worker", as: :pwa_service_worker
|
|
|
|
# Defines the root path route ("/")
|
|
root "pages#home"
|
|
|
|
# === Devise ===
|
|
# Routes for devise authentication Gem
|
|
# Bind devise to user
|
|
devise_for :users, path: "auth", path_names: {
|
|
sign_in: "sign_in", # Route for user login
|
|
sign_out: "sign_out", # Route for user logout
|
|
password: "reset-password", # Route for changing password
|
|
confirmation: "verification", # Route for account confirmation
|
|
unlock: "unblock", # Route for account unlock
|
|
# registration: "account", # Route for user account
|
|
sign_up: "signup" # Route for user registration
|
|
},
|
|
controllers: {
|
|
sessions: "authentications/sessions", # Custom controller for sessions
|
|
registrations: "authentications/registrations", # Custom controller for registrations
|
|
passwords: "authentications/passwords", # Custom controller for passwords
|
|
confirmation: "authentications/confirmations" # Custom controller for confirmations
|
|
}
|
|
|
|
# === Pages ===
|
|
get "dashboard", to: "pages#dashboard", as: "dashboard"
|
|
|
|
# === Promoter Routes ===
|
|
namespace :promoter do
|
|
resources :events do
|
|
member do
|
|
patch :publish
|
|
patch :unpublish
|
|
patch :cancel
|
|
patch :mark_sold_out
|
|
end
|
|
|
|
# Nested ticket types routes
|
|
resources :ticket_types do
|
|
member do
|
|
post :duplicate
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
# === Events ===
|
|
get "events", to: "events#index", as: "events"
|
|
get "events/:slug.:id", to: "events#show", as: "event"
|
|
|
|
# === Tickets ===
|
|
get "events/:slug.:id/tickets/new", to: "tickets#new", as: "ticket_new"
|
|
post "events/:slug.:id/tickets/create", to: "tickets#create", as: "ticket_create"
|
|
get "events/:slug.:id/tickets/checkout", to: "tickets#checkout", as: "ticket_checkout"
|
|
post "events/:slug.:id/tickets/retry", to: "tickets#retry_payment", as: "ticket_retry_payment"
|
|
|
|
# Payment routes
|
|
get "payments/success", to: "tickets#payment_success", as: "payment_success"
|
|
get "payments/cancel", to: "tickets#payment_cancel", as: "payment_cancel"
|
|
|
|
# === Tickets ===
|
|
get "tickets/:ticket_id/download", to: "events#download_ticket", as: "download_ticket"
|
|
|
|
# API routes versioning
|
|
namespace :api do
|
|
namespace :v1 do
|
|
# RESTful routes for event management
|
|
resources :events, only: [ :index, :show, :create, :update, :destroy ] do
|
|
member do
|
|
post :store_cart
|
|
end
|
|
end
|
|
# resources :ticket_types, only: [ :index, :show, :create, :update, :destroy ]
|
|
end
|
|
end
|
|
end
|