Module: check_mk
Branch: master
Commit: c5941cc2dd38cf2a403fd9931ccbf54fd1f5d2db
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c5941cc2dd38cf…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Fri Jul 27 12:48:12 2018 +0200
Add missing topics for attributes in the personal settings section
Add the topic "personal" to the personal settings of a user.
This fixes a bug that the personal settings of a user did
not load completely and saving a user resulted in a crash.
Change-Id: I4cf7c1912061bb38cc4f6c7c3881f326f6b88edc
---
cmk/gui/plugins/userdb/user_attributes.py | 20 ++++++++++++++++++++
cmk/gui/plugins/userdb/utils.py | 11 ++++++-----
cmk/gui/wato/__init__.py | 2 +-
3 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/cmk/gui/plugins/userdb/user_attributes.py
b/cmk/gui/plugins/userdb/user_attributes.py
index db08f37..bde8b0e 100644
--- a/cmk/gui/plugins/userdb/user_attributes.py
+++ b/cmk/gui/plugins/userdb/user_attributes.py
@@ -36,6 +36,10 @@ class ForceAuthUserUserAttribute(UserAttribute):
return "force_authuser"
+ def topic(self):
+ return "personal"
+
+
def valuespec(self):
return Checkbox(
title = _("Visibility of Hosts/Services"),
@@ -59,6 +63,10 @@ class ForceAuthUserWebserviceUserAttribute(UserAttribute):
return "force_authuser_webservice"
+ def topic(self):
+ return "personal"
+
+
def valuespec(self):
return Checkbox(
title = _("Hosts/Service visibility (Webservice, Deprecated)"),
@@ -82,6 +90,10 @@ class DisableNotificationsUserAttribute(UserAttribute):
return "disable_notifications"
+ def topic(self):
+ return "personal"
+
+
def valuespec(self):
return Transform(Dictionary(
title=_("Disable Notifications"),
@@ -123,6 +135,10 @@ class StartURLUserAttribute(UserAttribute):
return "start_url"
+ def topic(self):
+ return "personal"
+
+
def valuespec(self):
return Transform(
Alternative(
@@ -161,6 +177,10 @@ class UIThemeUserAttribute(UserAttribute):
return "ui_theme"
+ def topic(self):
+ return "personal"
+
+
def valuespec(self):
return Alternative(
title = _("User interface theme"),
diff --git a/cmk/gui/plugins/userdb/utils.py b/cmk/gui/plugins/userdb/utils.py
index 5872229..7ea3146 100644
--- a/cmk/gui/plugins/userdb/utils.py
+++ b/cmk/gui/plugins/userdb/utils.py
@@ -147,6 +147,12 @@ class UserAttribute(object):
@abc.abstractmethod
+ def topic(self):
+ # type: () -> bytes
+ raise NotImplementedError()
+
+
+ @abc.abstractmethod
def valuespec(self):
raise NotImplementedError()
@@ -171,11 +177,6 @@ class UserAttribute(object):
return False
- def topic(self):
- # type: () -> Optional[bytes]
- return None
-
-
def add_custom_macro(self):
# type: () -> bool
return False
diff --git a/cmk/gui/wato/__init__.py b/cmk/gui/wato/__init__.py
index 01efc21..951ab20 100644
--- a/cmk/gui/wato/__init__.py
+++ b/cmk/gui/wato/__init__.py
@@ -10707,7 +10707,7 @@ class ModeEditUser(WatoMode):
)
- def _show_custom_user_attributes(self, topic=None):
+ def _show_custom_user_attributes(self, topic):
for name, attr in userdb.get_user_attributes():
if topic is not None and topic != attr.topic():
continue # skip attrs of other topics