From c9e77654c1c55ce9f126be3c48a9b6e914103ec5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Gaya?= Date: Mon, 2 Jun 2025 09:51:07 +0200 Subject: [PATCH] bring back the not_too_long validator --- .../website/agenda/event/with_kinds.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/models/communication/website/agenda/event/with_kinds.rb b/app/models/communication/website/agenda/event/with_kinds.rb index ceee8c02c..13abc8e63 100644 --- a/app/models/communication/website/agenda/event/with_kinds.rb +++ b/app/models/communication/website/agenda/event/with_kinds.rb @@ -6,7 +6,7 @@ module Communication::Website::Agenda::Event::WithKinds validate :no_child_before?, if: :kind_parent? validate :no_child_after?, if: :kind_parent? - # validate :not_too_long # Uncomment when Rennes is ready + validate :not_too_long before_validation :set_to_day after_save :manage_time_slots @@ -62,13 +62,13 @@ def no_child_after? end end - # def not_too_long - # max_duration_in_days = MAX_DURATION / 1.day - # if duration_in_days > max_duration_in_days - # max_end_date = from_day + max_duration_in_days - # errors.add(:to_day, :too_long, max_end_date: max_end_date) - # end - # end + def not_too_long + max_duration_in_days = MAX_DURATION / 1.day + if duration_in_days > max_duration_in_days + max_end_date = from_day + max_duration_in_days + errors.add(:to_day, :too_long, max_end_date: max_end_date) + end + end def set_to_day if kind_child?