Module: check_mk
Branch: master
Commit: 8b3971990af634c254289085ed62e447c867a30d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8b3971990af634…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Nov 8 10:26:29 2012 +0100
Notifications editable by user himself
---
web/htdocs/default_permissions.py | 7 +++++++
web/htdocs/wato.py | 26 ++++++++++++++++++++++----
2 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/web/htdocs/default_permissions.py b/web/htdocs/default_permissions.py
index 2a51b64..d2c3a4c 100644
--- a/web/htdocs/default_permissions.py
+++ b/web/htdocs/default_permissions.py
@@ -111,6 +111,13 @@ def load():
[ 'admin', 'user' ]
)
+ 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 '
+ '<i>Edit the user profile</i> in order to do this.'),
+ [ 'admin', 'user' ]
+ )
+
config.declare_permission('general.change_password',
_('Edit the user password'),
_('Permits the user to change the password.'),
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 174f78b..cd017b5 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -11027,6 +11027,10 @@ def page_user_profile():
# load the new language
load_language(config.get_language())
+ if config.may('general.edit_notifications'):
+ value = forms.get_input(vs_notification_method,
"notification_method")
+ users[config.user_id]["notification_method"] = value
+
# Change the password if requested
if config.may('general.change_password'):
password = html.var('password')
@@ -11059,15 +11063,19 @@ def page_user_profile():
if html.has_user_errors():
html.show_user_errors()
+ users = load_users()
+ user = users.get(config.user_id)
+ if user == None:
+ html.warning(_("Sorry, your user account does not exist."))
+ html.footer()
+ return
+
html.begin_form("profile", method="POST")
html.write('<div class=wato>')
forms.header(_("Personal Settings"))
forms.section(_("Name"), simple=True)
- html.write(config.user_id)
-
- if config.may('general.edit_profile'):
- select_language(config.get_language(''))
+ html.write(user["alias"])
if config.may('general.change_password'):
forms.section(_("Password"))
@@ -11076,6 +11084,16 @@ def page_user_profile():
forms.section(_("Password confirmation"))
html.password_input('password2')
+ if config.may('general.edit_profile'):
+ select_language(config.get_language(''))
+ # Let the user configure how he wants to be notified
+ if config.may('general.edit_notifications') and
user.get("notifications_enabled"):
+ forms.section(_("Notifications"))
+ html.help(_("Here you can configure how you want to be notified about
host and service problems and "
+ "other monitoring events."))
+ vs_notification_method.render_input("notification_method",
user.get("notification_method"))
+ # forms.input(vs_notification_method, "notification_method",
user.get("notification_method"))
+
# Save button
forms.end()
html.button("_save", _("Save"))