Module: check_mk
Branch: master
Commit: bbb9e7d637949798b7d24e69faca82734ae6dc08
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bbb9e7d6379497…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Thu Dec 15 14:50:28 2016 +0100
4167 Notification plugins: now can be hidden by role
Change-Id: Ic32bc7fb331de069adc85896ec373bfc8f27a5ba
---
.werks/4167 | 11 +++++++++++
ChangeLog | 1 +
web/htdocs/notifications.py | 23 ++++++++++++++++++++---
web/htdocs/wato.py | 14 +++++++++++---
4 files changed, 43 insertions(+), 6 deletions(-)
diff --git a/.werks/4167 b/.werks/4167
new file mode 100644
index 0000000..8d0608b
--- /dev/null
+++ b/.werks/4167
@@ -0,0 +1,11 @@
+Title: Notification plugins: now can be hidden by role
+Level: 1
+Component: wato
+Compatible: compat
+Version: 1.4.0i3
+Date: 1481809695
+Class: feature
+
+In each role setting you can specify for the notification plugins
+whether they will be hidden for this role or not. Default setting
+is 'yes' for each plugin.
diff --git a/ChangeLog b/ChangeLog
index 7dccb84..adca56c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -102,6 +102,7 @@
* 3984 Permissions can now be filtered by providing a search term on the "edit
role" page...
* 4044 Display host/service notification delay with d/h/m/s, not with fractions of
minute
* 4075 Activate Changes has been reworked...
+ * 4167 Notification plugins: now can be hidden by role...
* 4039 FIX: Fix UnicodeEncodeError exception in WATO folder display...
* 4041 FIX: Fix exception when editing global configuration settings...
* 3975 FIX: Improved error handling when trying to edit not existing global setting
diff --git a/web/htdocs/notifications.py b/web/htdocs/notifications.py
index 09b6de6..a5b696b 100644
--- a/web/htdocs/notifications.py
+++ b/web/htdocs/notifications.py
@@ -35,9 +35,26 @@ import wato
g_acknowledgement_time = {}
-g_modified_time = 0
-
-g_columns = ["time", "contact_name", "type",
"host_name", "service_description", "comment"]
+g_modified_time = 0
+g_columns = ["time", "contact_name", "type",
"host_name",
+ "service_description", "comment"]
+loaded_with_language = False
+
+
+def load_plugins(force):
+ global loaded_with_language
+ if loaded_with_language == current_language and not force:
+ return
+
+ config.declare_permission_section("notification_plugin",
+ _("Notification plugins"),
+ do_sort = True)
+
+ for name, attrs in wato.load_notification_scripts().items():
+ config.declare_permission(
+ "notification_plugin.%s" % name,
+ _u(attrs["title"]), u"",
+ [ "admin", "user" ])
def acknowledge_failed_notifications(timestamp):
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index f8efdb5..3608b81 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -7734,7 +7734,11 @@ def mode_notifications(phase):
return
- rules = load_notification_rules()
+ rules = []
+ for rule in load_notification_rules():
+ if config.user.may("notification_plugin.%s" %
rule['notify_plugin'][0]) and \
+ rule not in rules:
+ rules.append(rule)
if phase == "action":
if html.has_var("_show_user"):
@@ -8135,7 +8139,12 @@ def load_notification_scripts():
def notification_script_choices():
- return user_script_choices("notifications") + [(None, _("ASCII Email
(legacy)")) ]
+ choices = []
+ for choice in user_script_choices("notifications") + [(None, _("ASCII
Email (legacy)")) ]:
+ notificaton_plugin_name, notification_plugin_title = choice
+ if config.user.may("notification_plugin.%s" %
notificaton_plugin_name):
+ choices.append( choice )
+ return choices
def notification_script_choices_with_parameters():
@@ -8166,7 +8175,6 @@ def notification_script_title(name):
return user_script_title("notifications", name)
-
#.
# .--Timeperiods---------------------------------------------------------.
# | _____ _ _ _ |