Module: check_mk
Branch: master
Commit: 8c84835ea5614b9ea23b58d796cc3b187fc8cbea
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8c84835ea5614b…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Dec 21 14:58:40 2015 +0100
Code refactoring: prepare for recurring downtimes with non-uniform periods
---
web/htdocs/views.py | 1 +
web/plugins/views/commands.py | 41 ++++++++++++++++++++---------------------
web/plugins/views/painters.py | 19 +++++++++----------
3 files changed, 30 insertions(+), 31 deletions(-)
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 017f76d..7398f1b 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -1103,6 +1103,7 @@ def show_view(view, show_heading = False, show_buttons = True,
else:
rows = []
+
# Apply non-Livestatus filters
for filter in all_active_filters:
rows = filter.filter_table(rows)
diff --git a/web/plugins/views/commands.py b/web/plugins/views/commands.py
index db8de3b..bce0edc 100644
--- a/web/plugins/views/commands.py
+++ b/web/plugins/views/commands.py
@@ -495,26 +495,24 @@ multisite_commands.append({
# | |
# '----------------------------------------------------------------------'
-recurring_types = {
- 1: _("hour"),
- 2: _("day"),
- 3: _("week"),
- 4: _("second week"),
- 5: _("fourth week"),
-}
-
config.declare_permission("action.downtimes",
_("Set/Remove Downtimes"),
_("Schedule and remove downtimes on hosts and services"),
[ "user", "admin" ])
def command_downtime(cmdtag, spec, row):
+ try:
+ wato.recurring_downtimes_types
+ have_recurring_downtimes = True
+ except:
+ have_recurring_downtimes = False
+
down_from = int(time.time())
down_to = None
- if html.get_checkbox("_down_do_recur"):
+ if have_recurring_downtimes and html.get_checkbox("_down_do_recur"):
recurring_type = int(html.var("_down_recurring"))
- title_start = _("schedule a periodic downtime every %s") %
recurring_types[recurring_type]
+ title_start = _("schedule a periodic downtime every %s") %
wato.recurring_downtimes_types[recurring_type]
else:
title_start = _("schedule an immediate downtime")
@@ -711,17 +709,18 @@ def paint_downtime_buttons(what):
html.write("<hr>")
html.checkbox("_on_hosts", False, label=_('Schedule downtimes on
the affected <b>hosts</b> instead of on the individual services'))
- html.write("<hr>")
- html.checkbox("_down_do_recur", False, label=_("Repeat this downtime
on a regular base every"))
- html.write(" ")
- html.select("_down_recurring", [
- ( "1", _("hour") ),
- ( "2", _("day") ),
- ( "3", _("week") ),
- ( "4", _("second week") ),
- ( "5", _("fourth week") ),
- ], "3")
- html.write(_("(This only works when using CMC)"))
+ try:
+ wato.recurring_downtimes_types # Check if this exists
+ have_recurring_downtimes = True
+ except:
+ have_recurring_downtimes = False
+
+ if have_recurring_downtimes:
+ html.write("<hr>")
+ html.checkbox("_down_do_recur", False, label=_("Repeat this
downtime on a regular base every"))
+ html.write(" ")
+ html.select("_down_recurring", [ (str(k), v) for (k,v) in
sorted(wato.recurring_downtimes_types.items())], "3")
+ html.write(_("(This only works when using CMC)"))
diff --git a/web/plugins/views/painters.py b/web/plugins/views/painters.py
index e845043..af76f73 100644
--- a/web/plugins/views/painters.py
+++ b/web/plugins/views/painters.py
@@ -1927,17 +1927,16 @@ multisite_painters["downtime_origin"] = {
}
def paint_downtime_recurring(row):
+ try:
+ wato.recurring_downtimes_types
+ except:
+ return "", _("(not supported)")
+
r = row["downtime_recurring"]
- return "", {
- 0: _("no"),
- None: _("no"),
- 1: _("hourly"),
- 2: _("daily"),
- 3: _("weekly"),
- 4: _("two-weekly"),
- 5: _("four-weekly"),
- 999: _("every 5 minutes"),
- }.get(r, _("(unknown)"))
+ if not r:
+ return "", _("no")
+ else:
+ return "", wato.recurring_downtimes_types.get(r, _("(unknown:
%d)") % r)
multisite_painters["downtime_recurring"] = {
"title" : _("Downtime recurring interval"),