From f09295807489d214033fb2edc63d7b4b92bf6108 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Gaya?= <sebastien.gaya@gmail.com>
Date: Fri, 9 Feb 2024 10:30:30 +0100
Subject: [PATCH] methods

---
 .../communication/website/agenda/event/with_time.rb       | 8 ++++++++
 .../communication/websites/agenda/events/_dates.html.erb  | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/app/models/communication/website/agenda/event/with_time.rb b/app/models/communication/website/agenda/event/with_time.rb
index 9da9f67fc..ea401cbbb 100644
--- a/app/models/communication/website/agenda/event/with_time.rb
+++ b/app/models/communication/website/agenda/event/with_time.rb
@@ -47,6 +47,14 @@ module Communication::Website::Agenda::Event::WithTime
     from_day == to_day
   end
 
+  def has_hours?
+    from_hour.present? || to_hour.present?
+  end
+
+  def has_specific_time_zone?
+    time_zone != website.default_time_zone
+  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
diff --git a/app/views/admin/communication/websites/agenda/events/_dates.html.erb b/app/views/admin/communication/websites/agenda/events/_dates.html.erb
index 68a6fb78e..5fbfedcf5 100644
--- a/app/views/admin/communication/websites/agenda/events/_dates.html.erb
+++ b/app/views/admin/communication/websites/agenda/events/_dates.html.erb
@@ -21,7 +21,7 @@ day_format = detailed ? :full
     <%= l(event.to_hour, format: :time_only) if event.to_hour %>
   <% end %>
 <% end %>
-<% unless event.from_hour.nil? && event.to_hour.nil? || event.time_zone == @website.default_time_zone %>
+<% if event.has_hours? && event.has_specific_time_zone? %>
   <br>
   <%= t('admin.communication.website.agenda.events.formatted_time_zone', time_zone: event.time_zone) %>
 <% end %>
\ No newline at end of file
-- 
GitLab