Module: check_mk
Branch: master
Commit: f57fbff1275fb9a5e760c86d8685f641864f8fb4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f57fbff1275fb9…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Jul 22 11:40:14 2013 +0200
FIX: fix validation of time-of-day input field (24:00)
---
ChangeLog | 1 +
web/htdocs/valuespec.py | 10 ++++++----
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e149c02..b168a8d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -272,6 +272,7 @@
WATO:
* FIX: fix layout of Auxiliary tags table
* FIX: avoid exception when called first time and first page ist host tags
+ * FIX: fix validation of time-of-day input field (24:00)
1.2.2p2:
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 8129be0..2803593 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -1597,10 +1597,12 @@ class Timeofday(ValueSpec):
def validate_value(self, value, varprefix):
if not self._allow_empty and value == None:
raise MKUserError(varprefix, _("Please enter a time."))
- if self._allow_24_00 and value > (24, 0):
- raise MKUserError(varprefix, _("The time must not be greater than
24:00."))
- elif not self._allow_empty and value > (23, 59):
- raise MKUserError(varprefix, _("The time must not be greater than
23:59."))
+ if self._allow_24_00:
+ max_value = (24, 0)
+ else:
+ max_value = (23, 59)
+ if value > max_value:
+ raise MKUserError(varprefix, _("The time must not be greater than
%02d:%02d." % max_value))
elif value[0] < 0 or value[1] < 0 or value[0] > 24 or value[1] > 59:
raise MKUserError(varprefix, _("Hours/Minutes out of range"))
ValueSpec.custom_validate(self, value, varprefix)