refactor: migrate payment success views to orders system and add promoter seed data
All checks were successful
Ruby on Rails Test / rails-test (push) Successful in 1m48s

This commit is contained in:
kbe
2025-09-16 21:32:42 +02:00
parent 3e0a354a58
commit e5ed1a34dd
6 changed files with 81 additions and 304 deletions

View File

@@ -1,150 +0,0 @@
<div class="min-h-screen bg-gradient-to-br from-purple-50 to-indigo-50 py-12 px-4 sm:px-6">
<div class="max-w-3xl mx-auto">
<div class="bg-white rounded-2xl shadow-xl overflow-hidden">
<!-- Header -->
<div class="bg-gradient-to-r from-purple-600 to-indigo-700 px-6 py-8 text-center">
<div class="flex justify-center mb-4">
<div class="w-16 h-16 rounded-full bg-white/20 flex items-center justify-center">
<svg class="w-8 h-8 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
</svg>
</div>
</div>
<h1 class="text-3xl font-bold text-white mb-2">Paiement réussi !</h1>
<p class="text-purple-100">Félicitations pour votre achat</p>
</div>
<!-- Content -->
<div class="p-6 sm:p-8">
<div class="text-center mb-8">
<p class="text-xl text-gray-700">
Vos billets pour <span class="font-bold text-purple-700"><%= @event.name %></span> ont été achetés avec succès.
</p>
<p class="text-gray-500 mt-2">
Un email de confirmation avec vos billets a été envoyé à <span class="font-medium"><%= current_user.email %></span>
</p>
</div>
<!-- Event Details -->
<div class="bg-gray-50 rounded-xl p-6 mb-8">
<h2 class="text-xl font-bold text-gray-900 mb-4 flex items-center">
<svg class="w-5 h-5 mr-2 text-purple-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"></path>
</svg>
Détails de l'événement
</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="flex items-center p-3 bg-white rounded-lg">
<svg class="w-5 h-5 text-purple-500 mr-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"></path>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 11a3 3 0 11-6 0 3 3 0 016 0z"></path>
</svg>
<div>
<p class="text-xs text-gray-500">Lieu</p>
<p class="font-medium"><%= @event.venue_name %></p>
</div>
</div>
<div class="flex items-center p-3 bg-white rounded-lg">
<svg class="w-5 h-5 text-purple-500 mr-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
<div>
<p class="text-xs text-gray-500">Date & Heure</p>
<p class="font-medium"><%= @event.start_time.strftime("%d %B %Y à %H:%M") %></p>
</div>
</div>
</div>
</div>
<!-- Tickets -->
<div class="mb-8">
<h2 class="text-xl font-bold text-gray-900 mb-4 flex items-center">
<svg class="w-5 h-5 mr-2 text-purple-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 5v2m0 4v2m0 4v2M5 5a2 2 0 00-2 2v3a2 2 0 110 4v3a2 2 0 002 2h14a2 2 0 002-2v-3a2 2 0 110-4V7a2 2 0 00-2-2H5z"></path>
</svg>
Vos billets
</h2>
<div class="space-y-4">
<% @tickets.each do |ticket| %>
<div class="bg-gradient-to-r from-purple-50 to-indigo-50 rounded-xl border border-purple-100 p-5">
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
<div class="flex-1">
<div class="flex items-center">
<div class="w-10 h-10 rounded-lg bg-purple-100 flex items-center justify-center mr-4">
<svg class="w-5 h-5 text-purple-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 5v2m0 4v2m0 4v2M5 5a2 2 0 00-2 2v3a2 2 0 110 4v3a2 2 0 002 2h14a2 2 0 002-2v-3a2 2 0 110-4V7a2 2 0 00-2-2H5z"></path>
</svg>
</div>
<div>
<h3 class="font-bold text-gray-900"><%= ticket.ticket_type.name %></h3>
<p class="text-sm text-gray-600">Prix: <span class="font-medium"><%= number_to_currency(ticket.price_cents / 100.0, unit: "€") %></span></p>
</div>
</div>
</div>
<div class="flex items-center space-x-2">
<%= link_to ticket_download_path(ticket.qr_code, format: :pdf),
class: "inline-flex items-center px-4 py-2 btn btn-primary rounded-lg transition-all duration-200 text-sm font-medium shadow-sm" do %>
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
</svg>
Télécharger PDF
<% end %>
</div>
</div>
<div class="mt-4 pt-4 border-t border-purple-100 flex items-center justify-between">
<div class="flex items-center">
<svg class="w-4 h-4 text-gray-500 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"></path>
</svg>
<span class="text-xs text-gray-500">Code QR: <%= ticket.qr_code[0..7] %></span>
</div>
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
Actif
</span>
</div>
</div>
<% end %>
</div>
</div>
<!-- Important Notice -->
<div class="bg-blue-50 border border-blue-100 rounded-xl p-5 mb-8">
<div class="flex">
<svg class="w-5 h-5 text-blue-500 mr-3 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
<div>
<h3 class="font-bold text-blue-800 mb-1">Important</h3>
<p class="text-sm text-blue-700">
Veuillez télécharger et sauvegarder vos billets. Présentez-les à l'entrée du lieu pour accéder à l'événement.
Un email de confirmation avec vos billets a été envoyé à votre adresse email.
</p>
</div>
</div>
</div>
<!-- Action Buttons -->
<div class="flex flex-col sm:flex-row gap-4 justify-center">
<%= link_to dashboard_path,
class: "inline-flex items-center justify-center px-6 py-3 btn btn-primary rounded-xl transition-all duration-200 font-medium shadow-sm" do %>
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"></path>
</svg>
Tableau de bord
<% end %>
<%= link_to events_path,
class: "inline-flex items-center justify-center px-6 py-3 bg-white text-gray-700 rounded-xl border border-gray-300 hover:bg-gray-50 transition-all duration-200 font-medium shadow-sm" do %>
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"></path>
</svg>
Voir plus d'événements
<% end %>
</div>
</div>
</div>
</div>
</div>

View File

@@ -102,7 +102,7 @@
<!-- Order Total --> <!-- Order Total -->
<div class=" pt-12"> <div class=" pt-12">
<div class="space-y-2"> <div class="space-y-2">
<div class="flex items-center justify-between text-lg pt-2 border-t border-gray-200"> <div class="flex items-center justify-between text-lg pt-2">
<span class="font-medium text-gray-900">Total</span> <span class="font-medium text-gray-900">Total</span>
<span class="font-bold text-2xl text-purple-600"><%= @order.total_amount_euros %>€</span> <span class="font-bold text-2xl text-purple-600"><%= @order.total_amount_euros %>€</span>
</div> </div>

View File

@@ -126,7 +126,7 @@
<!-- Total --> <!-- Total -->
<div class="mt-6"> <div class="mt-6">
<div class="space-y-2"> <div class="space-y-2">
<div class="flex items-center justify-between text-lg pt-2 border-t border-gray-200"> <div class="flex items-center justify-between text-lg pt-2">
<span class="font-medium text-gray-900">Total payé</span> <span class="font-medium text-gray-900">Total payé</span>
<span class="font-bold text-2xl text-green-600"> <span class="font-bold text-2xl text-green-600">
<%= @order.total_amount_euros %>€ <%= @order.total_amount_euros %>€

View File

@@ -96,7 +96,7 @@
<!-- Total --> <!-- Total -->
<div class="border-t border-gray-200 pt-6 mt-6"> <div class="border-t border-gray-200 pt-6 mt-6">
<div class="flex items-center justify-between text-lg pt-2 border-t border-gray-200"> <div class="flex items-center justify-between text-lg pt-2">
<span class="font-medium text-gray-900">Total <%= @order.status == 'paid' || @order.status == 'completed' ? 'payé' : 'à payer' %></span> <span class="font-medium text-gray-900">Total <%= @order.status == 'paid' || @order.status == 'completed' ? 'payé' : 'à payer' %></span>
<span class="font-bold text-2xl <%= @order.status == 'paid' || @order.status == 'completed' ? 'text-green-600' : 'text-purple-600' %>"> <span class="font-bold text-2xl <%= @order.status == 'paid' || @order.status == 'completed' ? 'text-green-600' : 'text-purple-600' %>">
<%= @order.total_amount_euros %>€ <%= @order.total_amount_euros %>€
@@ -212,4 +212,4 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -1,150 +0,0 @@
<div class="min-h-screen bg-gradient-to-br from-purple-50 to-indigo-50 py-12 px-4 sm:px-6">
<div class="max-w-3xl mx-auto">
<div class="bg-white rounded-2xl shadow-xl overflow-hidden">
<!-- Header -->
<div class="bg-gradient-to-r from-purple-600 to-indigo-700 px-6 py-8 text-center">
<div class="flex justify-center mb-4">
<div class="w-16 h-16 rounded-full bg-white/20 flex items-center justify-center">
<svg class="w-8 h-8 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
</svg>
</div>
</div>
<h1 class="text-3xl font-bold text-white mb-2">Paiement réussi !</h1>
<p class="text-purple-100">Félicitations pour votre achat</p>
</div>
<!-- Content -->
<div class="p-6 sm:p-8">
<div class="text-center mb-8">
<p class="text-xl text-gray-700">
Vos billets pour <span class="font-bold text-purple-700"><%= @event.name %></span> ont été achetés avec succès.
</p>
<p class="text-gray-500 mt-2">
Un email de confirmation avec vos billets a été envoyé à <span class="font-medium"><%= current_user.email %></span>
</p>
</div>
<!-- Event Details -->
<div class="bg-gray-50 rounded-xl p-6 mb-8">
<h2 class="text-xl font-bold text-gray-900 mb-4 flex items-center">
<svg class="w-5 h-5 mr-2 text-purple-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"></path>
</svg>
Détails de l'événement
</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="flex items-center p-3 bg-white rounded-lg">
<svg class="w-5 h-5 text-purple-500 mr-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"></path>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 11a3 3 0 11-6 0 3 3 0 016 0z"></path>
</svg>
<div>
<p class="text-xs text-gray-500">Lieu</p>
<p class="font-medium"><%= @event.venue_name %></p>
</div>
</div>
<div class="flex items-center p-3 bg-white rounded-lg">
<svg class="w-5 h-5 text-purple-500 mr-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
<div>
<p class="text-xs text-gray-500">Date & Heure</p>
<p class="font-medium"><%= @event.start_time.strftime("%d %B %Y à %H:%M") %></p>
</div>
</div>
</div>
</div>
<!-- Tickets -->
<div class="mb-8">
<h2 class="text-xl font-bold text-gray-900 mb-4 flex items-center">
<svg class="w-5 h-5 mr-2 text-purple-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 5v2m0 4v2m0 4v2M5 5a2 2 0 00-2 2v3a2 2 0 110 4v3a2 2 0 002 2h14a2 2 0 002-2v-3a2 2 0 110-4V7a2 2 0 00-2-2H5z"></path>
</svg>
Vos billets
</h2>
<div class="space-y-4">
<% @tickets.each do |ticket| %>
<div class="bg-gradient-to-r from-purple-50 to-indigo-50 rounded-xl border border-purple-100 p-5">
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
<div class="flex-1">
<div class="flex items-center">
<div class="w-10 h-10 rounded-lg bg-purple-100 flex items-center justify-center mr-4">
<svg class="w-5 h-5 text-purple-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 5v2m0 4v2m0 4v2M5 5a2 2 0 00-2 2v3a2 2 0 110 4v3a2 2 0 002 2h14a2 2 0 002-2v-3a2 2 0 110-4V7a2 2 0 00-2-2H5z"></path>
</svg>
</div>
<div>
<h3 class="font-bold text-gray-900"><%= ticket.ticket_type.name %></h3>
<p class="text-sm text-gray-600">Prix: <span class="font-medium"><%= number_to_currency(ticket.price_cents / 100.0, unit: "€") %></span></p>
</div>
</div>
</div>
<div class="flex items-center space-x-2">
<%= link_to ticket_download_path(ticket.qr_code, format: :pdf),
class: "inline-flex items-center px-4 py-2 btn btn-primary rounded-lg transition-all duration-200 text-sm font-medium shadow-sm" do %>
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
</svg>
Télécharger PDF
<% end %>
</div>
</div>
<div class="mt-4 pt-4 border-t border-purple-100 flex items-center justify-between">
<div class="flex items-center">
<svg class="w-4 h-4 text-gray-500 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"></path>
</svg>
<span class="text-xs text-gray-500">Code QR: <%= ticket.qr_code[0..7] %></span>
</div>
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
Actif
</span>
</div>
</div>
<% end %>
</div>
</div>
<!-- Important Notice -->
<div class="bg-blue-50 border border-blue-100 rounded-xl p-5 mb-8">
<div class="flex">
<svg class="w-5 h-5 text-blue-500 mr-3 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
<div>
<h3 class="font-bold text-blue-800 mb-1">Important</h3>
<p class="text-sm text-blue-700">
Veuillez télécharger et sauvegarder vos billets. Présentez-les à l'entrée du lieu pour accéder à l'événement.
Un email de confirmation avec vos billets a été envoyé à votre adresse email.
</p>
</div>
</div>
</div>
<!-- Action Buttons -->
<div class="flex flex-col sm:flex-row gap-4 justify-center">
<%= link_to dashboard_path,
class: "inline-flex items-center justify-center px-6 py-3 btn btn-primary rounded-xl transition-all duration-200 font-medium shadow-sm" do %>
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"></path>
</svg>
Tableau de bord
<% end %>
<%= link_to events_path,
class: "inline-flex items-center justify-center px-6 py-3 bg-white text-gray-700 rounded-xl border border-gray-300 hover:bg-gray-50 transition-all duration-200 font-medium shadow-sm" do %>
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"></path>
</svg>
Voir plus d'événements
<% end %>
</div>
</div>
</div>
</div>
</div>

View File

@@ -112,3 +112,80 @@ events.each_with_index do |event, index|
end end
puts "Created #{User.count} users, #{Event.count} events, and #{TicketType.count} ticket types" 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"