Module: check_mk
Branch: master
Commit: dff573b2942742c9c8298d41c791e0e9e1b75a94
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=dff573b2942742…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Sep 26 17:41:48 2018 +0200
6724 FIX Add missing permission for viewing host/service availability
A new permission named "See the availability" has been added. It can
be used to hide the availability context buttons and views from users.
Change-Id: I9086935086b0bb4bb016833b9b09a4e93b1c0d54
---
.werks/6724 | 12 ++++++++++++
cmk/gui/default_permissions.py | 5 +++++
cmk/gui/plugins/views/availability.py | 3 +++
cmk/gui/views.py | 2 +-
4 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/.werks/6724 b/.werks/6724
new file mode 100644
index 0000000..d394452
--- /dev/null
+++ b/.werks/6724
@@ -0,0 +1,12 @@
+Title: Add missing permission for viewing host/service availability
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1537976434
+
+A new permission named "See the availability" has been added. It can
+be used to hide the availability context buttons and views from users.
diff --git a/cmk/gui/default_permissions.py b/cmk/gui/default_permissions.py
index 9b68ef9..15d0400 100644
--- a/cmk/gui/default_permissions.py
+++ b/cmk/gui/default_permissions.py
@@ -103,6 +103,11 @@ def load_plugins(force):
[ 'admin', 'user' ]
)
+ config.declare_permission("general.see_availability",
+ _("See the availability"),
+ _("See the availability views of hosts and services"),
+ [ "admin", "user", "guest" ])
+
config.declare_permission('general.edit_notifications',
_('Edit personal notification settings'),
_('This allows a user to edit his personal notification settings. You also need the permission '
diff --git a/cmk/gui/plugins/views/availability.py b/cmk/gui/plugins/views/availability.py
index e0ee642..6150a03 100644
--- a/cmk/gui/plugins/views/availability.py
+++ b/cmk/gui/plugins/views/availability.py
@@ -148,6 +148,7 @@ def render_availability_options(what):
# is (currently) called by views.py, when showing a view but
# availability mode is activated.
def render_availability_page(view, datasource, context, filterheaders, only_sites, limit):
+ config.user.need_permission("general.see_availability")
if handle_edit_annotations():
return
@@ -508,6 +509,8 @@ def render_timeline_bar(timeline_layout, style):
# logic for getting the aggregates. As soon as we have cleaned of the visuals,
# filters, contexts etc we can unify the code!
def render_bi_availability(title, aggr_rows):
+ config.user.need_permission("general.see_availability")
+
av_mode = html.var("av_mode", "availability")
avoptions = get_availability_options_from_url("bi")
if av_mode == "timeline":
diff --git a/cmk/gui/views.py b/cmk/gui/views.py
index 535115a..6067a10 100644
--- a/cmk/gui/views.py
+++ b/cmk/gui/views.py
@@ -1512,7 +1512,7 @@ def show_context_links(thisview, datasource, show_filters,
html.context_button(_("Edit View"), url, "edit", id="edit", bestof=config.context_buttons_to_show)
if display_options.enabled(display_options.E):
- if show_availability:
+ if show_availability and config.user.may("general.see_availability"):
html.context_button(_("Availability"), html.makeuri([("mode", "availability")]), "availability")
if show_combined_graphs and config.combined_graphs_available():
html.context_button(_("Combined graphs"),
Module: check_mk
Branch: master
Commit: 5c0b9f7eecb78b90a4457ebcdd9a7a69b5bcc70d
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5c0b9f7eecb78b…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Sep 26 17:07:45 2018 +0200
6720 FIX Bulk mail notifications: Single notifications in bulks use non-bulk subject
All 1.5 releases were always using the bulk notification subjects for mails.
Previous versions were using the single notification subject in case a bulk
notification only contained a single notification. This has been changed back
to the original behaviour.
Change-Id: I9c4e16b024e0b0124bdc510582cb0de3a2fa24fe
---
.werks/6720 | 14 ++++++++++++++
cmk/notification_plugins/asciimail.py | 5 ++++-
cmk/notification_plugins/mail.py | 5 ++++-
3 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/.werks/6720 b/.werks/6720
new file mode 100644
index 0000000..051b61d
--- /dev/null
+++ b/.werks/6720
@@ -0,0 +1,14 @@
+Title: Bulk mail notifications: Single notifications in bulks use non-bulk subject
+Level: 1
+Component: notifications
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1537967537
+
+All 1.5 releases were always using the bulk notification subjects for mails.
+Previous versions were using the single notification subject in case a bulk
+notification only contained a single notification. This has been changed back
+to the original behaviour.
diff --git a/cmk/notification_plugins/asciimail.py b/cmk/notification_plugins/asciimail.py
index 3826661..0483056 100644
--- a/cmk/notification_plugins/asciimail.py
+++ b/cmk/notification_plugins/asciimail.py
@@ -152,7 +152,10 @@ def main():
mailto = context['CONTACTEMAIL'] # Assume the same in each context
subject = context['SUBJECT']
hosts.add(context["HOSTNAME"])
- subject = utils.get_bulk_notification_subject(contexts, hosts)
+
+ # Use the single context subject in case there is only one context in the bulk
+ if len(contexts) > 1:
+ subject = utils.get_bulk_notification_subject(contexts, hosts)
else:
# gather all options from env
diff --git a/cmk/notification_plugins/mail.py b/cmk/notification_plugins/mail.py
index f55892a..3a6882f 100644
--- a/cmk/notification_plugins/mail.py
+++ b/cmk/notification_plugins/mail.py
@@ -933,7 +933,10 @@ def main():
mailto = context['CONTACTEMAIL'] # Assume the same in each context
subject = context['SUBJECT']
hosts.add(context["HOSTNAME"])
- subject = utils.get_bulk_notification_subject(contexts, hosts)
+
+ # Use the single context subject in case there is only one context in the bulk
+ if len(contexts) > 1:
+ subject = utils.get_bulk_notification_subject(contexts, hosts)
else:
# gather all options from env
Module: check_mk
Branch: master
Commit: 972c896248150e97878a8e70d00bf96553961954
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=972c896248150e…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Sep 26 14:48:35 2018 +0200
6719 FIX Simplified user setting: Temporarily disable notifications
The user profile setting for temporarily disabling all notifications was
a set of two nested checkboxes which both had to be checked for
disabling the notifications. This has now been fixed to be only a single
checkbox again.
Change-Id: Ie5131f189bbd385dd9153e000db89a9c9f5377a9
---
.werks/6719 | 13 +++++++++++++
cmk/gui/plugins/userdb/user_attributes.py | 5 ++++-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/.werks/6719 b/.werks/6719
new file mode 100644
index 0000000..0d37c60
--- /dev/null
+++ b/.werks/6719
@@ -0,0 +1,13 @@
+Title: Simplified user setting: Temporarily disable notifications
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1537964762
+
+The user profile setting for temporarily disabling all notifications was a set
+of two nested checkboxes which both had to be checked for disabling the
+notifications. This has now been fixed to be only a single checkbox again.
diff --git a/cmk/gui/plugins/userdb/user_attributes.py b/cmk/gui/plugins/userdb/user_attributes.py
index 171ee5f..af69171 100644
--- a/cmk/gui/plugins/userdb/user_attributes.py
+++ b/cmk/gui/plugins/userdb/user_attributes.py
@@ -104,7 +104,10 @@ class DisableNotificationsUserAttribute(UserAttribute):
"sure that you know what you do. Moreover you can customize a timerange "
"within no notifications are generated."),
elements = [
- ("disable", Checkbox(title=_("Temporarily disable <b>all</b> notifications!"), label=_("Disable"))),
+ ("disable", FixedValue(True,
+ title=_("Temporarily disable <b>all</b> notifications!"),
+ totext="",
+ )),
("timerange", Tuple(title=_("Customize timerange"), elements = [
AbsoluteDate(title=_("From:"), include_time=True),
AbsoluteDate(title=_("To:"), include_time=True),
Module: check_mk
Branch: master
Commit: 22f699ea7d41ec7c6522f3765a83cc86aa6c2d75
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=22f699ea7d41ec…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Sep 19 07:47:46 2018 +0200
Moved urlfunc handling to Dashlet()
Change-Id: If7e10545e895ad86331eebcf755d973a4a019392
---
cmk/gui/dashboard.py | 36 +-------------------------
cmk/gui/plugins/dashboard/utils.py | 53 ++++++++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+), 35 deletions(-)
diff --git a/cmk/gui/dashboard.py b/cmk/gui/dashboard.py
index 1d9eb1c..74f5a4a 100644
--- a/cmk/gui/dashboard.py
+++ b/cmk/gui/dashboard.py
@@ -260,7 +260,6 @@ class LegacyDashlet(cmk.gui.plugins.dashboard.Dashlet):
return super(LegacyDashlet, self)._get_iframe_url()
-
# Pre Check_MK 1.6 the dashlets were declared with dictionaries like this:
#
# dashlet_types["hoststats"] = {
@@ -536,9 +535,6 @@ def draw_dashboard(name):
dashlet_container_begin(nr, dashlet)
try:
- # TODO: Fix this
- gather_dashlet_url(dashlet)
-
# TODO: Make use of dashlet_instance here
register_for_refresh(name, board, nr, dashlet, wato_folder)
register_for_on_resize(name, board, nr, dashlet, wato_folder)
@@ -758,7 +754,7 @@ def used_dashlet_types(board):
# refreshed by us but need to do that themselves.
def register_for_refresh(name, board, nr, dashlet, wato_folder):
dashlet_type = get_dashlet_type(dashlet)
- if "url" in dashlet or (not dashlet_type.is_iframe_dashlet() and dashlet_type.refresh_interval()):
+ if dashlet_type.type_name() == "url" or (not dashlet_type.is_iframe_dashlet() and dashlet_type.refresh_interval()):
refresh = dashlet.get("refresh", dashlet_type.refresh_interval())
if not refresh:
return
@@ -807,36 +803,6 @@ def get_dashlet(board, ident):
raise MKGeneralException(_('The dashlet does not exist.'))
-# Use the URL returned by urlfunc as dashlet URL
-#
-# We need to support function pointers to be compatible to old dashboard plugin
-# based definitions. The new dashboards use strings to reference functions within
-# the global context or functions of a module. An example would be:
-#
-# urlfunc: "my_custom_url_rendering_function"
-#
-# or within a module:
-#
-# urlfunc: "my_module.render_my_url"
-def gather_dashlet_url(dashlet):
- # dashlets using the 'urlfunc' method will dynamically compute
- # an url (using HTML context variables at their wish).
- if "urlfunc" not in dashlet:
- return
-
- urlfunc = dashlet['urlfunc']
- if type(urlfunc) == type(lambda x: x):
- dashlet["url"] = urlfunc()
- else:
- if '.' in urlfunc:
- module_name, func_name = urlfunc.split('.', 1)
- module = __import__(module_name)
- fp = module.__dict__[func_name]
- else:
- fp = globals()[urlfunc]
- dashlet["url"] = fp()
-
-
# Create the HTML code for one dashlet. Each dashlet has an id "dashlet_%d",
# where %d is its index (in board["dashlets"]). Javascript uses that id
# for the resizing. Within that div there is an inner div containing the
diff --git a/cmk/gui/plugins/dashboard/utils.py b/cmk/gui/plugins/dashboard/utils.py
index 64620ae..9e64a68 100644
--- a/cmk/gui/plugins/dashboard/utils.py
+++ b/cmk/gui/plugins/dashboard/utils.py
@@ -165,6 +165,11 @@ class Dashlet(object):
self._wato_folder = wato_folder
+ @property
+ def dashlet_id(self):
+ return self._dashlet_id
+
+
def display_title(self):
return self.title()
@@ -285,6 +290,54 @@ class Dashlet(object):
return None
+ def _get_refresh_url(self):
+ """Returns the URL to be used for loading the dashlet contents"""
+ dashlet_url = self._get_dashlet_url_from_urlfunc()
+ if dashlet_url is not None:
+ return dashlet_url
+
+ if self._dashlet.get("url"):
+ return self._dashlet["url"]
+
+ return html.makeuri_contextless([
+ ("name", self._dashboard_name),
+ ("id", self._dashlet_id),
+ ], filename="dashboard_dashlet.py")
+
+
+ # TODO: This is specific for the 'url' dashlet type. Move it to that
+ # dashlets class once it has been refactored to a class
+ def _get_dashlet_url_from_urlfunc(self):
+ """Use the URL returned by urlfunc as dashlet URL
+
+ Dashlets using the 'urlfunc' method will dynamically compute
+ an url (using HTML context variables at their wish).
+
+ We need to support function pointers to be compatible to old dashboard plugin
+ based definitions. The new dashboards use strings to reference functions within
+ the global context or functions of a module. An example would be:
+
+ urlfunc: "my_custom_url_rendering_function"
+
+ or within a module:
+
+ urlfunc: "my_module.render_my_url"
+ """
+ if "urlfunc" not in self._dashlet:
+ return None
+
+ urlfunc = self._dashlet['urlfunc']
+ if type(urlfunc) == type(lambda x: x):
+ return urlfunc()
+
+ if '.' in urlfunc:
+ module_name, func_name = urlfunc.split('.', 1)
+ module = __import__(module_name)
+ return module.__dict__[func_name]()
+
+ return globals()[urlfunc]()
+
+
class DashletRegistry(cmk.gui.plugin_registry.ClassRegistry):
Module: check_mk
Branch: master
Commit: 5929dedb5f647d67dcddbc309a55b00e7f047180
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5929dedb5f647d…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Aug 31 08:27:44 2018 +0200
Refactored dashlet plugin registering to new plugin registry
* All existing dashlets still use the old API
* Add compatibility layer (LegacyDashlet()) to be able to still work
with dashlets using the old dashlet API
* Add tests to verify LegacyDashlet() functionality
Change-Id: If90b4bc1b1dc346e989e0113f5c40cc28ff1e02d
---
cmk/gui/dashboard.py | 389 +++++++++++++++++++++-------------
cmk/gui/plugins/dashboard/__init__.py | 2 +
cmk/gui/plugins/dashboard/dashlets.py | 5 +-
cmk/gui/plugins/dashboard/utils.py | 267 ++++++++++++++++++++++-
tests/unit/web/test_dashboard.py | 155 ++++++++++++++
5 files changed, 670 insertions(+), 148 deletions(-)
Diff: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=5929dedb5f…