Module: check_mk
Branch: master
Commit: 8fc9dad203cc5c78c7a3174095cc0921858c4784
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8fc9dad203cc5c…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Mar 21 11:12:26 2016 +0100
3314 FIX Correctly add custom user attribute values after change in attribute declaration
If you redeclared this attributes as "make available for notifications" it
would
be added only after once modifying any actual user. This has been fixed.
---
.werks/3314 | 11 +++++++++++
ChangeLog | 1 +
web/htdocs/userdb.py | 4 ++++
web/htdocs/wato.py | 6 +++++-
4 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/.werks/3314 b/.werks/3314
new file mode 100644
index 0000000..476b92c
--- /dev/null
+++ b/.werks/3314
@@ -0,0 +1,11 @@
+Title: Correctly add custom user attribute values after change in attribute declaration
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1458555064
+
+If you redeclared this attributes as "make available for notifications" it
would
+be added only after once modifying any actual user. This has been fixed.
diff --git a/ChangeLog b/ChangeLog
index d58ab9a..9fd108c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -153,6 +153,7 @@
* 3011 FIX: WATO host diagnostic page: prevent incorrectly filled input fields...
* 3295 FIX: Fixed exception in WATO git integration when modifying .gitingore file
* 3296 FIX: Hiding pending changes related buttons after discarding changes
+ * 3314 FIX: Correctly add custom user attribute values after change in attribute
declaration...
Notifications:
* 3263 Notifications: allow users to restrict by their contact groups...
diff --git a/web/htdocs/userdb.py b/web/htdocs/userdb.py
index ac7c219..d17678a 100644
--- a/web/htdocs/userdb.py
+++ b/web/htdocs/userdb.py
@@ -609,6 +609,10 @@ def save_users(profiles):
hooks.call("users-saved", profiles)
+def rewrite_users():
+ users = load_users(lock = True)
+ save_users(users)
+
def contactgroups_of_user(user_id):
users = load_users()
if user_id not in users:
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index cf17f2a..2f4e479 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -14350,7 +14350,7 @@ def mode_edit_custom_attr(phase, what):
log_pending(SYNCRESTART, None, "edit-%sattr" % what,
_("Create new %s attribute %s") % (what, name))
else:
- log_pending(SYNCRESTART, None, "edit-%sattr" % what,
_("Changed title of %s attribute %s") % (what, name))
+ log_pending(SYNCRESTART, None, "edit-%sattr" % what,
_("Modified %s attribute %s") % (what, name))
attr.update({
'title' : title,
'topic' : topic,
@@ -14361,6 +14361,10 @@ def mode_edit_custom_attr(phase, what):
})
save_custom_attrs(all_attrs)
+ if what == "user":
+ userdb.declare_custom_user_attrs()
+ userdb.rewrite_users()
+
return what + "_attrs"