aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/calendar/period.rb6
-rw-r--r--config/locales/calendars.en.yml1
-rw-r--r--config/locales/calendars.fr.yml1
3 files changed, 5 insertions, 3 deletions
diff --git a/app/models/calendar/period.rb b/app/models/calendar/period.rb
index bfde242f3..1c423dfcc 100644
--- a/app/models/calendar/period.rb
+++ b/app/models/calendar/period.rb
@@ -11,8 +11,8 @@ class Calendar < ActiveRecord::Base
validate :check_end_greather_than_begin
def check_end_greather_than_begin
- if self.begin and self.end and self.begin > self.end
- errors.add(:end, :invalid)
+ if self.begin && self.end && self.begin >= self.end
+ errors.add(:base, I18n.t('calendars.errors.short_period'))
end
end
@@ -22,7 +22,7 @@ class Calendar < ActiveRecord::Base
end
def range
- if self.begin and self.end and self.begin <= self.end
+ if self.begin && self.end && self.begin <= self.end
Range.new self.begin, self.end
end
end
diff --git a/config/locales/calendars.en.yml b/config/locales/calendars.en.yml
index 456501b48..f6c5ba852 100644
--- a/config/locales/calendars.en.yml
+++ b/config/locales/calendars.en.yml
@@ -18,6 +18,7 @@ en:
destroy_confirm: Are you sure you want destroy this calendar?
errors:
overlapped_periods: Another period is overlapped with this period
+ short_period: A period needs to last at least two days
index:
title: Calendars
all: All
diff --git a/config/locales/calendars.fr.yml b/config/locales/calendars.fr.yml
index 44b474045..1b403c3f2 100644
--- a/config/locales/calendars.fr.yml
+++ b/config/locales/calendars.fr.yml
@@ -31,6 +31,7 @@ fr:
destroy_confirm: Etes vous sûr de supprimer cet calendrier ?
errors:
overlapped_periods: Une autre période chevauche cette période
+ short_period: Une période doit être d'un duréé de deux jours minimum
index:
title: Calendriers
all: Tous