new modes

This commit is contained in:
kb6e
2025-08-25 20:17:44 +02:00
parent 6fbd24e36e
commit 6385c39c10
38 changed files with 385 additions and 302 deletions

View File

@@ -0,0 +1,10 @@
class EventsController < ApplicationController
# Display all events
def index
@parties = Party.includes(:user).upcoming.page(params[:page]).per(12)
end
# Display desired event
def show
end
end

View File

@@ -15,4 +15,9 @@ class PagesController < ApplicationController
# Accessible only to authenticated users
def dashboard
end
# Events page showing all published parties with pagination
def events
@parties = Party.published.order(created_at: :desc).page(params[:page])
end
end

View File

@@ -1,2 +1,5 @@
module ApplicationHelper
def format_price(cents)
(cents.to_f / 100).round(2)
end
end

View File

@@ -43,4 +43,7 @@ class Party < ApplicationRecord
scope :featured, -> { where(featured: true) } # Get featured parties for homepage
scope :published, -> { where(state: :published) } # Get publicly visible parties
scope :search_by_name, ->(query) { where("name ILIKE ?", "%#{query}%") } # Search by name (case-insensitive)
# Scope for published parties ordered by start time
scope :upcoming, -> { published.where("start_time >= ?", Time.current).order(start_time: :asc) }
end

View File

@@ -12,7 +12,7 @@
<!-- Navigation Links -->
<div class="hidden space-x-8 sm:-my-px sm:ms-10 sm:flex items-center">
<%= link_to "Soirées et afterworks", "#", class: "text-white hover:text-purple-200 px-3 py-2 rounded-md text-sm font-medium transition-colors duration-200" %>
<%= link_to "Soirées et afterworks", events_path, class: "text-white hover:text-purple-200 px-3 py-2 rounded-md text-sm font-medium transition-colors duration-200" %>
<%= link_to "Concerts", "#", class: "text-white hover:text-purple-200 px-3 py-2 rounded-md text-sm font-medium transition-colors duration-200" %>
</div>
</div>

View File

@@ -0,0 +1,52 @@
<div class="container mx-auto px-4 sm:px-6 lg:px-8 py-8">
<h1 class="text-3xl font-bold text-gray-900 mb-8">Événements à venir</h1>
<% if @parties.any? %>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<% @parties.each do |party| %>
<div class="bg-white rounded-lg shadow-md overflow-hidden hover:shadow-lg transition-shadow duration-300">
<div class="p-6">
<div class="flex justify-between items-start">
<div>
<h2 class="text-xl font-bold text-gray-900"><%= party.name %></h2>
<p class="text-sm text-gray-500 mt-1"><%= party.user.email %></p>
</div>
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-purple-100 text-purple-800">
<%= party.start_time.strftime("%d/%m/%Y") %>
</span>
</div>
<div class="mt-4">
<p class="text-gray-600 text-sm line-clamp-2"><%= party.description.truncate(100) %></p>
</div>
<div class="mt-4 flex justify-between items-center">
<div>
<% if party.ticket_types.any? %>
<p class="text-sm font-medium text-gray-900">
À partir de <%= format_price(party.ticket_types.minimum(:price_cents)) %>€
</p>
<% else %>
<p class="text-sm text-gray-500">Pas de billets disponibles</p>
<% end %>
</div>
<%= link_to "Voir les détails", party_path(party), class: "inline-flex items-center px-3 py-1.5 border border-transparent text-xs font-medium rounded-full shadow-sm text-white bg-purple-600 hover:bg-purple-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-purple-500" %>
</div>
</div>
</div>
<% end %>
</div>
<div class="mt-8">
<%= paginate @parties, theme: 'twitter_bootstrap' %>
</div>
<% else %>
<div class="text-center py-12">
<svg class="mx-auto h-12 w-12 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<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" />
</svg>
<h3 class="mt-2 text-sm font-medium text-gray-900">Aucun événement disponible</h3>
<p class="mt-1 text-sm text-gray-500">Il n'y a aucun événement à venir pour le moment.</p>
</div>
<% end %>

View File

@@ -0,0 +1,46 @@
<div class="container mx-auto px-4 py-8">
<h1 class="text-3xl font-bold mb-8">Upcoming Events</h1>
<% if @parties.any? %>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<% @parties.each do |party| %>
<div class="bg-white rounded-lg shadow-md overflow-hidden">
<% if party.image.present? %>
<img src="<%= party.image %>" alt="<%= party.name %>" class="w-full h-48 object-cover">
<% else %>
<div class="bg-gray-200 border-2 border-dashed rounded-xl w-full h-48 flex items-center justify-center">
<span class="text-gray-500">No Image</span>
</div>
<% end %>
<div class="p-6">
<h2 class="text-xl font-semibold mb-2"><%= party.name %></h2>
<p class="text-gray-600 mb-4"><%= party.description.truncate(100) %></p>
<div class="flex justify-between items-center">
<div>
<p class="text-sm text-gray-500"><%= party.venue_name %></p>
<p class="text-sm text-gray-500"><%= party.venue_address %></p>
</div>
<div>
<span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-blue-100 text-blue-800">
<%= party.state.humanize %>
</span>
</div>
</div>
</div>
</div>
<% end %>
</div>
<!-- Pagination -->
<div class="mt-8 flex justify-center">
<%= paginate @parties %>
</div>
<% else %>
<div class="text-center py-12">
<h2 class="text-xl font-medium text-gray-900 mb-4">No events found</h2>
<p class="text-gray-500">Check back later for upcoming events.</p>
</div>
<% end %>
</div>