Module: check_mk
Branch: master
Commit: 3df24a62f7bdc38610065b0241c44b02d883ee82
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3df24a62f7bdc3…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Sep 7 13:35:11 2017 +0200
5198 FIX Delete contact groups: Fixed error message when users have no alias
The error message that prevents the deletion of a contact group when it is
assigned to a user could contain the text "User: None" when a user had no
alias set. In case there is no alias for the user it shows the user ID now.
Change-Id: Ic16c4697d4d670af3e260072eaffe72d585887ae
---
.werks/5198 | 13 +++++++++++++
web/htdocs/watolib.py | 5 ++---
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/.werks/5198 b/.werks/5198
new file mode 100644
index 0000000..be00eb6
--- /dev/null
+++ b/.werks/5198
@@ -0,0 +1,13 @@
+Title: Delete contact groups: Fixed error message when users have no alias
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1504784015
+
+The error message that prevents the deletion of a contact group when it is
+assigned to a user could contain the text "User: None" when a user had no
+alias set. In case there is no alias for the user it shows the user ID now.
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index 7398d0e..d53d07b 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -8555,11 +8555,10 @@ def find_usages_of_contact_group(name):
# Is the contactgroup assigned to a user?
users = userdb.load_users()
entries = users.items()
- entries.sort(cmp = lambda a, b: cmp(a[1].get("alias"),
b[1].get("alias")))
- for userid, user in entries:
+ for userid, user in sorted(entries, key=lambda x: x[1].get("alias",
x[0])):
cgs = user.get("contactgroups", [])
if name in cgs:
- used_in.append(('%s: %s' % (_('User'),
user.get('alias')),
+ used_in.append(('%s: %s' % (_('User'),
user.get('alias', userid)),
folder_preserving_link([('mode', 'edit_user'),
('edit', userid)])))
global_config = load_configuration_settings()