Module: check_mk
Branch: master
Commit: d4cbfafedcf5f1306a8aabe7360e64222fb0dd66
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d4cbfafedcf5f1…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Nov 14 17:16:26 2011 +0100
FIX: Disallow settings downtimes that end in the past
---
ChangeLog | 1 +
web/htdocs/htmllib.py | 5 +++++
web/htdocs/views.py | 4 ++++
3 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b9dafa4..a301df6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -58,6 +58,7 @@
Multisite:
* FIX: Fixed encoding problem when opening dashboard
* FIX: Fixed styling of view header in older IE browsers
+ * FIX: Disallow settings downtimes that end in the past
Livestatus:
* New columns num_hosts and num_services in status table
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index 68f10a8..8f1a1d8 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -462,6 +462,11 @@ class html:
except:
t = default_value
+ if varname in self.user_errors:
+ self.add_user_error(varname + "_date", self.user_errors[varname])
+ self.add_user_error(varname + "_time", self.user_errors[varname])
+ self.set_focus(varname + "_date")
+
br = time.localtime(t)
self.date_input(varname + "_date", br.tm_year, br.tm_mon, br.tm_mday)
self.write(" ")
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 5f0d6c8..f663e03 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -2176,6 +2176,10 @@ def nagios_host_service_action_command(what, dataset):
elif html.var("_down_custom") and
config.may("action.downtimes"):
down_from = html.get_datetime_input("_down_from")
down_to = html.get_datetime_input("_down_to")
+ if down_to < time.time():
+ raise MKUserError("_down_to", _("You cannot set a downtime
that ends in the past. "
+ "This incident will be reported."))
+
title = _("<b>schedule a downtime from %s to %s</b> on ") %
(
time.asctime(time.localtime(down_from)),
time.asctime(time.localtime(down_to)))