I added the features for users to use promotion code and for promoters to create on their events. May be rewrite to discount code?
306 lines
12 KiB
Ruby
Executable File
306 lines
12 KiB
Ruby
Executable File
# This file should ensure the existence of records required to run the application in every environment (production,
|
|
# development, test). The code here should be idempotent so that it can be executed at any point in every environment.
|
|
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
|
|
#
|
|
# Example:
|
|
#
|
|
# ["Action", "Comedy", "Drama", "Horror"].each do |genre_name|
|
|
# MovieGenre.find_or_create_by!(name: genre_name)
|
|
# end
|
|
|
|
# Create admin user for development
|
|
admin_user = User.find_or_create_by!(email: "admin@example.com") do |u|
|
|
u.password = "password"
|
|
u.password_confirmation = "password"
|
|
u.last_name = nil
|
|
u.first_name = nil
|
|
end
|
|
|
|
# Create regular users for development
|
|
users = User.where.not(email: "admin@example.com").limit(5)
|
|
missing_users_count = 5 - users.count
|
|
missing_users_count.times do |i|
|
|
User.find_or_create_by!(email: "user#{i + 1}@example.com") do |u|
|
|
u.password = "password"
|
|
u.password_confirmation = "password"
|
|
u.last_name = nil
|
|
u.first_name = nil
|
|
end
|
|
end
|
|
|
|
# Reload all users after creation
|
|
users = User.all.to_a
|
|
|
|
# Create sample events
|
|
events_data = [
|
|
{
|
|
name: "Summer Beach Event",
|
|
slug: "summer-beach-event",
|
|
description: "Join us for an amazing night at the beach with music, dancing, and cocktails.",
|
|
venue_name: "Sunset Beach Resort",
|
|
venue_address: "123 Ocean Drive, Miami, FL",
|
|
latitude: 25.7617,
|
|
longitude: -80.1918,
|
|
start_time: 1.day.from_now,
|
|
end_time: 1.day.from_now + 6.hours,
|
|
featured: true,
|
|
image: "https://fastly.picsum.photos/id/407/300/200.jpg?hmac=9EhoXMZ1QdwJue90vzxcjBg2YzsZsAWCjJ7oxOhtcU0",
|
|
user: users.first
|
|
},
|
|
{
|
|
name: "Rooftop Jazz Night",
|
|
slug: "rooftop-jazz-night",
|
|
description: "Experience smooth jazz under the stars at our exclusive rooftop venue.",
|
|
venue_name: "Skyline Rooftop Bar",
|
|
venue_address: "456 Downtown Ave, New York, NY",
|
|
latitude: 40.7128,
|
|
longitude: -74.0060,
|
|
start_time: 3.days.from_now,
|
|
end_time: 3.days.from_now + 4.hours,
|
|
featured: true,
|
|
image: "https://images.unsplash.com/photo-1511671782779-c97d3d27a1d4?ixlib=rb-4.0.3&auto=format&fit=crop&w=800&q=80",
|
|
user: users.second
|
|
},
|
|
{
|
|
name: "Warehouse Electronic Festival",
|
|
slug: "warehouse-electronic-festival",
|
|
description: "A night of electronic music and dancing in an industrial warehouse setting.",
|
|
venue_name: "Downtown Warehouse",
|
|
venue_address: "789 Industrial Blvd, Los Angeles, CA",
|
|
latitude: 34.0522,
|
|
longitude: -118.2437,
|
|
start_time: 1.week.from_now,
|
|
end_time: 1.week.from_now + 8.hours,
|
|
featured: false,
|
|
image: "https://images.unsplash.com/photo-1470225620780-dba8ba36b745?ixlib=rb-4.0.3&auto=format&fit=crop&w=800&q=80",
|
|
user: users.third
|
|
}
|
|
]
|
|
|
|
events = []
|
|
events_data.each do |event_data|
|
|
user = event_data.delete(:user)
|
|
event = Event.find_or_create_by!(name: event_data[:name]) do |p|
|
|
p.assign_attributes(event_data)
|
|
p.user = user
|
|
p.state = :published
|
|
end
|
|
events << event
|
|
end
|
|
|
|
# Create ticket types for each event
|
|
events.each_with_index do |event, index|
|
|
# General Admission ticket type
|
|
TicketType.find_or_create_by!(event: event, name: "General Admission") do |tt|
|
|
tt.description = "General admission ticket for #{event.name}"
|
|
tt.price_cents = 2500 # $25.00
|
|
tt.quantity = 100
|
|
tt.sale_start_at = 1.month.ago
|
|
tt.sale_end_at = event.start_time - 1.hour
|
|
tt.minimum_age = 18
|
|
end
|
|
|
|
# VIP ticket type
|
|
TicketType.find_or_create_by!(event: event, name: "VIP") do |tt|
|
|
tt.description = "VIP access ticket for #{event.name} with premium benefits"
|
|
tt.price_cents = 7500 # $75.00
|
|
tt.quantity = 20
|
|
tt.sale_start_at = 1.month.ago
|
|
tt.sale_end_at = event.start_time - 1.hour
|
|
tt.minimum_age = 21
|
|
end
|
|
end
|
|
|
|
puts "Created #{User.count} users, #{Event.count} events, and #{TicketType.count} ticket types"
|
|
|
|
# Create regular user as promoter
|
|
promoter = User.find_or_create_by!(email: "kbataille@vivaldi.net") do |u|
|
|
u.password = "lareunion974!"
|
|
u.password_confirmation = "lareunion974!"
|
|
u.last_name = nil
|
|
u.first_name = nil
|
|
u.is_professionnal = true
|
|
end
|
|
|
|
belle_epoque_event = Event.find_or_create_by!(name: "LA BELLE ÉPOQUE PAR SISLEY ÉVENTS") do |e|
|
|
e.slug = "la-belle-epoque-par-sisley-events"
|
|
e.state = :draft
|
|
e.description = "
|
|
Sisley évents Présente :
|
|
SAM 13 SEPT
|
|
LA BELLE ÉPOQUE de 18H à 2H
|
|
sur le Rooftop LE PATIO
|
|
ÉVÈNEMENT EN PLEIN AIR
|
|
Ambiance Rétro / old school : zouk , Ragga , kompa , Dancehall , hip hop , Groove , Rnb …
|
|
Restauration disponible sur place : Accras ,Allocos , specialités asiatique , japonaise et une large carte de choix de Pizzas pour vous régaler !
|
|
TARIF D'ENTRÉE : 10€ SUR PLACE UNIQUEMENT
|
|
Réservée aux + de 30 ans
|
|
Suivez nous sur Instagram : Sisley Évents
|
|
Le patio
|
|
38 avenue Leon Gaumont , Montreuil
|
|
Parking du Décathlon disponible , rue de la république, à 100m du Patio
|
|
"
|
|
e.venue_name = "Le Patio Rooftop"
|
|
e.venue_address = "38 Av. Léon Gaumont, 93100 Montreuil"
|
|
e.latitude = 48.862336
|
|
e.longitude = 2.441218
|
|
e.start_time = 3.days.from_now
|
|
e.end_time = 3.days.from_now + 8.hours
|
|
e.featured = false
|
|
e.image = "https://data.bizouk.com/cache1/events/images/10/78/87/b801a9a43266b4cc54bdda73bf34eec8_700_800_auto_97.jpg"
|
|
e.user = promoter
|
|
e.allow_booking_during_event = true
|
|
end
|
|
|
|
belle_epoque_event.update!(start_time: 3.days.from_now, end_time: 3.days.from_now + 8.hours)
|
|
|
|
|
|
# Create ticket types for "La belle époque" event
|
|
belle_epoque_event = Event.find_by!(slug: "la-belle-epoque-par-sisley-events")
|
|
|
|
TicketType.find_or_create_by!(event: belle_epoque_event, name: "Free invitation valid before 7 p.m.") do |tt|
|
|
tt.description = "Free invitation ticket valid before 7 p.m. for La Belle Époque"
|
|
tt.price_cents = 0
|
|
tt.quantity = 50
|
|
tt.sale_start_at = Time.current
|
|
tt.sale_end_at = belle_epoque_event.start_time
|
|
tt.minimum_age = 30
|
|
tt.requires_id = true
|
|
end
|
|
|
|
TicketType.find_or_create_by!(event: belle_epoque_event, name: "ENTRY 10€ TO BE PAYED ON SITE ONLY") do |tt|
|
|
tt.description = "Entry ticket to be paid on site only (free in system)"
|
|
tt.price_cents = 0
|
|
tt.quantity = 100
|
|
tt.sale_start_at = Time.current
|
|
tt.sale_end_at = belle_epoque_event.start_time
|
|
tt.minimum_age = 30
|
|
tt.requires_id = true
|
|
end
|
|
|
|
TicketType.find_or_create_by!(event: belle_epoque_event, name: "Paid Entry 10€") do |tt|
|
|
tt.description = "Paid entry ticket for La Belle Époque at 10€"
|
|
tt.price_cents = 1000 # 10€
|
|
tt.quantity = 200
|
|
tt.sale_start_at = Time.current
|
|
tt.sale_end_at = belle_epoque_event.start_time
|
|
tt.minimum_age = 30
|
|
tt.requires_id = true
|
|
end
|
|
|
|
puts "Created 1 promoter, 1 draft event with ticket types"
|
|
|
|
# Create additional events fetched from Bizouk
|
|
konpa_event = Event.find_or_create_by!(name: "Konpa With Bev - Cours De Konpa Gouyad") do |e|
|
|
e.slug = "konpa-with-bev-cours-de-konpa-gouyad"
|
|
e.description = "Séance ouverte à tous, débutant ou initié, venez perfectionner votre Konpa avec la talentueuse Beverly."
|
|
e.venue_name = "Guest Live"
|
|
e.venue_address = "36 Rue Marcel Dassault, 93140 Bondy"
|
|
e.latitude = 48.9096
|
|
e.longitude = 2.4836
|
|
e.start_time = Time.parse("2025-10-03 19:00:00")
|
|
e.end_time = Time.parse("2025-10-03 23:00:00")
|
|
e.featured = false
|
|
e.image = "https://data.bizouk.com/cache1/events/images/10/79/61/081f38b583ac651f3a0930c5d8f13458_800_600_auto_97.png"
|
|
e.user = promoter
|
|
e.state = :published
|
|
end
|
|
|
|
caribbean_groove_event = Event.find_or_create_by!(name: "La Plus Grosse Soirée Caribbean Groove") do |e|
|
|
e.slug = "la-plus-grosse-soiree-caribbean-groove"
|
|
e.description = "La CARIBBEAN GROOVE de 23H00 à 5h00... DJ DON BREEZY Aux Platines HIPHOP , RnB, zouk ,kompa , Dancehall, Afro.beat"
|
|
e.venue_name = "LE TOUT LE MONDE EN PARLE"
|
|
e.venue_address = "4 RUE DU DEPART 75015 PARIS"
|
|
e.latitude = 48.8406
|
|
e.longitude = 2.2935
|
|
e.start_time = Time.parse("2025-10-03 23:00:00")
|
|
e.end_time = Time.parse("2025-10-04 05:00:00")
|
|
e.featured = false
|
|
e.image = "https://data.bizouk.com/cache1/events/images/10/83/15/fa5d43f0b1998f691181cfda8fe35213_800_600_auto_97.png"
|
|
e.user = promoter
|
|
e.state = :published
|
|
end
|
|
|
|
belle_epoque_october_event = Event.find_or_create_by!(name: "LA BELLE ÉPOQUE PAR SISLEY ÉVENTS - OCTOBRE") do |e|
|
|
e.slug = "la-belle-epoque-par-sisley-events-octobre"
|
|
e.description = "SAM 4 OCTOBRE LA BELLE ÉPOQUE de 18H à 2H sur le Rooftop LE PATIO LA Dernière de la Saison ÉVÈNEMENT EN PLEIN AIR Ambiance Rétro / old school : zouk , Ragga , kompa , Dancehall , hip hop , Groove , Rnb … Restauration disponible sur place : Accras ,Allocos , specialités asiatique , japonaise et une large carte de choix de Pizzas pour vous régaler ! ENTRÉE LIBRE POUR TOUS AV 21H TARIF D'ENTRÉE : 10€ SUR PLACE UNIQUEMENT Réservée aux + de 30 ans Suivez nous sur Instagram : Sisley Évents"
|
|
e.venue_name = "Le Patio"
|
|
e.venue_address = "38 Avenue Leon Gaumont, 93100 Montreuil"
|
|
e.latitude = 48.862336
|
|
e.longitude = 2.441218
|
|
e.start_time = Time.parse("2025-10-04 18:00:00")
|
|
e.end_time = Time.parse("2025-10-05 02:00:00")
|
|
e.featured = false
|
|
e.image = "https://data.bizouk.com/cache1/events/images/10/92/72/351e61b55603a4d142b43486216457c1_800_600_auto_97.jpg"
|
|
e.user = promoter
|
|
e.state = :published
|
|
e.allow_booking_during_event = true
|
|
end
|
|
|
|
# Create ticket types for the new events
|
|
# Konpa event ticket types
|
|
TicketType.find_or_create_by!(event: konpa_event, name: "General Admission") do |tt|
|
|
tt.description = "General admission ticket for Konpa With Bev"
|
|
tt.price_cents = 1500 # $15.00
|
|
tt.quantity = 50
|
|
tt.sale_start_at = Time.current
|
|
tt.sale_end_at = konpa_event.start_time - 1.hour
|
|
tt.minimum_age = 18
|
|
end
|
|
|
|
# Caribbean Groove event ticket types
|
|
TicketType.find_or_create_by!(event: caribbean_groove_event, name: "General Admission") do |tt|
|
|
tt.description = "General admission ticket for Caribbean Groove"
|
|
tt.price_cents = 2000 # $20.00
|
|
tt.quantity = 100
|
|
tt.sale_start_at = Time.current
|
|
tt.sale_end_at = caribbean_groove_event.start_time - 1.hour
|
|
tt.minimum_age = 18
|
|
end
|
|
|
|
# Belle Époque October event ticket types
|
|
TicketType.find_or_create_by!(event: belle_epoque_october_event, name: "Free Entry Before 9 PM") do |tt|
|
|
tt.description = "Free entry before 9 PM for La Belle Époque October"
|
|
tt.price_cents = 0
|
|
tt.quantity = 50
|
|
tt.sale_start_at = Time.current
|
|
tt.sale_end_at = belle_epoque_october_event.start_time + 3.hours
|
|
tt.minimum_age = 30
|
|
tt.requires_id = true
|
|
end
|
|
|
|
TicketType.find_or_create_by!(event: belle_epoque_october_event, name: "Entry 10€ After 9 PM") do |tt|
|
|
tt.description = "Entry ticket 10€ after 9 PM for La Belle Époque October"
|
|
tt.price_cents = 1000 # 10€
|
|
tt.quantity = 150
|
|
tt.sale_start_at = Time.current
|
|
tt.sale_end_at = belle_epoque_october_event.start_time + 8.hours
|
|
tt.minimum_age = 30
|
|
tt.requires_id = true
|
|
end
|
|
|
|
puts "Created 3 additional events from Bizouk with ticket types"
|
|
|
|
# Create promotion codes for events
|
|
# Promotion code for belle_epoque_event
|
|
PromotionCode.find_or_create_by!(code: "BELLE10") do |pc|
|
|
pc.discount_amount_cents = 1000 # 10€ discount
|
|
pc.expires_at = belle_epoque_event.start_time + 1.day
|
|
pc.active = true
|
|
pc.usage_limit = 20
|
|
pc.user = promoter
|
|
pc.event = belle_epoque_october_event
|
|
end
|
|
|
|
# Promotion code for belle_epoque_october_event
|
|
PromotionCode.find_or_create_by!(code: "OCTOBRE5") do |pc|
|
|
pc.discount_amount_cents = 500 # 5€ discount
|
|
pc.expires_at = belle_epoque_october_event.start_time + 1.day
|
|
pc.active = true
|
|
pc.usage_limit = 30
|
|
pc.user = promoter
|
|
pc.event = belle_epoque_october_event
|
|
end
|
|
|
|
puts "Created promotion codes for events"
|