Module: check_mk
Branch: master
Commit: a49670d73946f96ec2aef36eefb8b9a160a852ac
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a49670d73946f9…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Tue Oct 11 12:53:24 2016 +0200
3957 mail: now allows extra HTML section between body and table
---
.werks/3957 | 9 +++++++++
ChangeLog | 3 +++
notifications/mail | 12 ++++++++----
web/plugins/wato/notifications.py | 10 +++++++++-
4 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/.werks/3957 b/.werks/3957
new file mode 100644
index 0000000..1072005
--- /dev/null
+++ b/.werks/3957
@@ -0,0 +1,9 @@
+Title: mail: now allows extra HTML section between body and table
+Level: 1
+Component: notifications
+Compatible: compat
+Version: 1.4.0i2
+Date: 1476183155
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index 9556f05..a2b3f40 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -25,6 +25,9 @@
* 3914 FIX: Roles: Aliases are now unique during cloning
* 3820 FIX: Network scan: no longer fails completely if hostname already exists in
configuration...
+ Notifications:
+ * 3957 mail: now allows extra HTML section between body and table
+
BI:
* 3955 BI rule ID can now be renamed
diff --git a/notifications/mail b/notifications/mail
index 6b3e7fe..abf9026 100755
--- a/notifications/mail
+++ b/notifications/mail
@@ -60,7 +60,8 @@ try:
except ImportError:
import json
-tmpl_head_html = '''
+def tmpl_head_html(html_section):
+ return '''
<html>
<head>
<title>$SUBJECT$</title>
@@ -224,8 +225,7 @@ table.context td {
</style>
</head>
-<body>
-<table>'''
+<body>''' + html_section + '<table>'
tmpl_foot_html = '''</table>
</body>
@@ -812,7 +812,11 @@ def construct_content(context):
except Exception, e:
sys.stderr.write("Failed to add graphs to mail. Continue without them.
(%s)\n" % e)
- content_html = substitute_context(tmpl_head_html, context) + \
+ extra_html_section = ""
+ if "PARAMETER_INSERT_HTML_SECTION" in context:
+ extra_html_section = context['PARAMETER_INSERT_HTML_SECTION']
+
+ content_html = substitute_context(tmpl_head_html(extra_html_section), context) + \
content_html + \
substitute_context(tmpl_foot_html, context)
diff --git a/web/plugins/wato/notifications.py b/web/plugins/wato/notifications.py
index c833139..e6abd28 100644
--- a/web/plugins/wato/notifications.py
+++ b/web/plugins/wato/notifications.py
@@ -168,7 +168,15 @@ register_notification_parameters(
],
optional_keys = ["auth", "encryption"]
)
- )
+ ),
+ ("insert_html_section",
+ TextAreaUnicode(
+ title = _("Insert HTML section between body and table"),
+ default_value = "<HTMLTAG>CONTENT</HTMLTAG>",
+ cols = 40,
+ rows = "auto",
+ ),
+ ),
]
)
)