From 52800e05c22303dfbbf3ddd146868aa88281a1e8 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Fri, 8 Sep 2023 05:31:35 +0200 Subject: [PATCH] events weight --- app/models/communication/website/agenda/event.rb | 6 ++++++ .../communication/websites/agenda/events/static.html.erb | 1 + 2 files changed, 7 insertions(+) diff --git a/app/models/communication/website/agenda/event.rb b/app/models/communication/website/agenda/event.rb index 8fd5c744a..700e01ee9 100644 --- a/app/models/communication/website/agenda/event.rb +++ b/app/models/communication/website/agenda/event.rb @@ -90,6 +90,12 @@ class Communication::Website::Agenda::Event < ApplicationRecord : from_day < Date.today end + # Un événement demain aura une distance de 1, comme un événement hier + # On utilise cette info pour classer les événements à venir dans un sens et les archives dans l'autre + def distance_in_days + (Date.today - from_day).to_i.abs + end + def git_path(website) return unless website.id == communication_website_id && published "#{git_path_content_prefix(website)}events/#{from_day.year}/#{from_day.strftime "%Y-%m-%d"}-#{slug}.html" diff --git a/app/views/admin/communication/websites/agenda/events/static.html.erb b/app/views/admin/communication/websites/agenda/events/static.html.erb index 7d90eae58..fc6d33d66 100644 --- a/app/views/admin/communication/websites/agenda/events/static.html.erb +++ b/app/views/admin/communication/websites/agenda/events/static.html.erb @@ -16,6 +16,7 @@ dates: <% if @about.to_hour %> hour: <%= @about.to_hour.strftime "%H:%M" %> <% end %> +weight: <%= @about.distance_in_days %> <%= render 'admin/application/static/permalink' %> <%= render 'admin/application/static/design', full_width: false, toc_offcanvas: false %> <%= render 'admin/application/i18n/static' %> -- GitLab