diff --git a/app/models/communication/website/agenda/event/with_kinds.rb b/app/models/communication/website/agenda/event/with_kinds.rb index 1ed0d5014..44849dc5a 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 @@ -70,13 +70,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?