Skip to content
Snippets Groups Projects
Commit 07c09ef0 authored by Arnaud Levy's avatar Arnaud Levy
Browse files
parent 17a9cd32
No related branches found
No related tags found
No related merge requests found
......@@ -60,7 +60,8 @@ class Communication::Website::Agenda::Event < ApplicationRecord
scope :ordered, -> { order(from_day: :desc, from_hour: :desc) }
scope :recent, -> { ordered.limit(5) }
validates_presence_of :from_day
validates_presence_of :from_day, :title
validate :to_day_after_from_day, :to_hour_after_from_hour_on_same_day
STATUS_FUTURE = 'future'
STATUS_PRESENT = 'present'
......@@ -116,4 +117,15 @@ class Communication::Website::Agenda::Event < ApplicationRecord
def to_s
"#{title}"
end
protected
def to_day_after_from_day
errors.add(:to_day, :too_soon) if to_day.present? && to_day < from_day
end
def to_hour_after_from_hour_on_same_day
return if from_day != to_day
errors.add(:to_hour, :too_soon) if to_hour.present? && from_hour.present? && to_hour < from_hour
end
end
......@@ -12,7 +12,7 @@ dates:
hour: <%= @about.from_hour.strftime "%H:%M" %>
<% end %>
to:
day: <%= @about.to_day || @about.from_day%>
day: <%= @about.to_day || @about.from_day %>
<% if @about.to_hour %>
hour: <%= @about.to_hour.strftime "%H:%M" %>
<% end %>
......
......@@ -233,6 +233,12 @@ en:
languages:
must_include_default: must include at least the default language
too_short: must include at least one
communication/website/agenda/event:
attributes:
to_day:
too_soon: must be after "from day"
to_hour:
too_soon: must be after "from hour"
admin:
communication:
blocks:
......
......@@ -233,6 +233,12 @@ fr:
languages:
must_include_default: doivent contenir la langue par défaut
too_short: doivent en comporter une minimum
communication/website/agenda/event:
attributes:
to_day:
too_soon: doit être après jour de début
to_hour:
too_soon: doit être après l'heure de début
admin:
communication:
blocks:
......
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