Module: check_mk
Branch: master
Commit: 3aa6dd04bc9263d1cd6543e191669d8202396c2b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3aa6dd04bc9263…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Nov 14 16:59:02 2014 +0100
New command option for expiration of acknowledgments
This only works with the CMC.
---
web/plugins/icons/builtin.py | 2 +-
web/plugins/views/builtin.py | 2 ++
web/plugins/views/commands.py | 18 ++++++++++++++++--
3 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/web/plugins/icons/builtin.py b/web/plugins/icons/builtin.py
index 4ff1809..47be9e7 100644
--- a/web/plugins/icons/builtin.py
+++ b/web/plugins/icons/builtin.py
@@ -375,7 +375,7 @@ multisite_icons.append({
# +----------------------------------------------------------------------+
def paint_comments(what, row, tags, custom_vars):
- comments = row[what+ "_comments_with_extra_info"]
+ comments = row[what + "_comments_with_extra_info"]
if len(comments) > 0:
text = ""
for c in comments:
diff --git a/web/plugins/views/builtin.py b/web/plugins/views/builtin.py
index 24725f5..efa9c92 100644
--- a/web/plugins/views/builtin.py
+++ b/web/plugins/views/builtin.py
@@ -323,6 +323,7 @@ multisite_builtin_views.update({
'painters': [('comment_author', None),
('comment_comment', None),
('comment_time', None),
+ ('comment_expires', None),
('comment_entry_type', None)],
'public': True,
'show_filters': [],
@@ -348,6 +349,7 @@ multisite_builtin_views.update({
'painters': [('comment_author', None),
('comment_comment', None),
('comment_time', None),
+ ('comment_expires', None),
('comment_entry_type', None)],
'public': True,
'show_filters': [],
diff --git a/web/plugins/views/commands.py b/web/plugins/views/commands.py
index 19d2605..493500f 100644
--- a/web/plugins/views/commands.py
+++ b/web/plugins/views/commands.py
@@ -270,12 +270,23 @@ def command_acknowledgement(cmdtag, spec, row):
comment = html.var_utf8("_ack_comment")
if not comment:
raise MKUserError("_ack_comment", _("You need to supply a
comment."))
+ if ";" in comment:
+ raise MKUserError("_ack_comment", _("The comment must not
contain semicolons."))
sticky = html.var("_ack_sticky") and 2 or 0
sendnot = html.var("_ack_notify") and 1 or 0
perscomm = html.var("_ack_persistent") and 1 or 0
+
+ expire_secs = Age().from_html_vars("_ack_expire")
+ if expire_secs:
+ expire = int(time.time()) + expire_secs
+ else:
+ expire = 0
+
command = "ACKNOWLEDGE_" + cmdtag + "_PROBLEM;%s;%d;%d;%d;%s"
% \
- (spec, sticky, sendnot, perscomm, config.user_id) +
(";%s" % lqencode(comment))
- title = _("<b>acknowledge the problems</b> of")
+ (spec, sticky, sendnot, perscomm, config.user_id) +
(";%s" % lqencode(comment)) \
+ + (";%d" % expire)
+ title = _("<b>acknowledge the problems%s</b> of") % \
+ (expire and (_(" for a period of %s") %
Age().value_to_text(expire_secs)) or "")
return command, title
elif html.var("_remove_ack"):
@@ -296,6 +307,9 @@ multisite_commands.append({
html.checkbox("_ack_notify", True, label=_("send
notification")) == \
html.checkbox("_ack_persistent", False, label=_('persistent
comment')) == \
html.write("<hr>") == \
+ Age(display=["days", "hours", "minutes"],
label=_("Expire acknowledgement after")).render_input("_ack_expire",
0) == \
+ html.help(_("Note: Expiration of acknowledgements only works when using the
Check_MK Micro Core.")) == \
+ html.write("<hr>") == \
html.write(_("Comment") + ": ") == \
html.text_input("_ack_comment", size=48,
submit="_acknowledge"),
"action" : command_acknowledgement,