Skip to content
Snippets Groups Projects
Commit 52800e05 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

events weight

parent 24437bb6
No related branches found
No related tags found
No related merge requests found
......@@ -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"
......
......@@ -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' %>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment