Module: check_mk
Branch: master
Commit: 8fc6944c67396dd6e6f5f2b98ec9b867ed2e7f47
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8fc6944c67396d…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Jan 31 10:09:17 2012 +0100
Reworked user language selection
---
web/htdocs/wato.py | 82 +++++++++++++++++++++++++--------------------------
1 files changed, 40 insertions(+), 42 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 59df3c3..866144d 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -6635,10 +6635,13 @@ def mode_edit_user(phase):
roles.keys())
# Language configuration
+ set_lang = html.var('_set_lang')
language = html.var('language')
- if language and language != config.default_language:
+ if set_lang and language != config.default_language:
+ if language == '':
+ language = None
new_user['language'] = language
- elif not language and 'language' in new_user:
+ elif not set_lang and 'language' in new_user:
del new_user['language']
# Contact groups
@@ -6689,7 +6692,7 @@ def mode_edit_user(phase):
html.write("<table class=form>")
# ID
- html.write("<tr><td class=legend>")
+ html.write("<tr><td class=legend colspan=2>")
html.write(_("Username"))
html.write("</td><td class=content>")
if new:
@@ -6701,7 +6704,7 @@ def mode_edit_user(phase):
html.write("</td></tr>")
# Full name
- html.write("<tr><td class=legend>")
+ html.write("<tr><td class=legend colspan=2>")
html.write(_("Full name") + "<br><i>" + _("Full
name or alias of the user</i>"))
html.write("</td><td class=content>")
html.text_input("alias", user.get("alias", userid), size = 50)
@@ -6710,7 +6713,7 @@ def mode_edit_user(phase):
html.write("</td></tr>")
# Authentication
- html.write("<tr><td class=legend>")
+ html.write("<tr><td class=legend colspan=2>")
html.write(_("Authentication<br><i>If you want the user to be able
to login "
"then specify a password here. Users without a login make sense
"
"if they are monitoring contacts that are just used for "
@@ -6745,7 +6748,7 @@ def mode_edit_user(phase):
html.write("</td></tr>")
# Locking
- html.write("<tr><td class=legend>")
+ html.write("<tr><td class=legend colspan=2>")
html.write(_("<i>Disabling the password will prevent a user from logging
in while "
"retaining the original password. Notifications are not affected
"
"by this setting.</i>"))
@@ -6755,7 +6758,7 @@ def mode_edit_user(phase):
html.write("</td></tr>")
# Email address
- html.write("<tr><td class=legend>")
+ html.write("<tr><td class=legend colspan=2>")
html.write(_("Email address<br><i>The email address is optional and
is needed "
"if the user is a monitoring contact and receives notifications
"
"via Email."))
@@ -6764,7 +6767,7 @@ def mode_edit_user(phase):
html.write("</td></tr>")
# Roles
- html.write("<tr><td class=legend>")
+ html.write("<tr><td class=legend colspan=2>")
html.write(_("Roles<br><i>By assigning roles to a user he obtains
permissions. "
"If a user has more then one role, he gets the maximum of all
"
"permissions of his roles. "
@@ -6780,7 +6783,7 @@ def mode_edit_user(phase):
html.write("</td></tr>")
# Contact groups
- html.write("<tr><td class=legend>")
+ html.write("<tr><td class=legend colspan=2>")
url1 = make_link([("mode", "contact_groups")])
url2 = make_link([("mode", "rulesets")])
html.write(_("Contact groups<br><i>Contact groups are used to assign
monitoring "
@@ -6808,7 +6811,7 @@ def mode_edit_user(phase):
html.write("</td></tr>")
# Notifications enabled
- html.write("<tr><td class=legend>")
+ html.write("<tr><td class=legend colspan=2>")
html.write(_("Notifications enabled<br><i>Notifications are sent out
"
"when the status of a host or service changes.</i>"))
html.write("</td><td class=content>")
@@ -6817,7 +6820,7 @@ def mode_edit_user(phase):
html.write("</td></tr>")
# Notification period
- html.write("<tr><td class=legend>")
+ html.write("<tr><td class=legend colspan=2>")
html.write(_("Notification time period<br><i>Only during this time
period the "
"user will get notifications about host or service alerts."))
html.write("</td><td class=content>")
@@ -6845,7 +6848,7 @@ def mode_edit_user(phase):
}
}
- html.write("<tr><td class=legend>")
+ html.write("<tr><td class=legend colspan=2>")
html.write(_("Notification options<br><i>Here you specify which
types of alerts "
"will be notified to this contact.</i>"))
html.write("</td><td class=content>")
@@ -6861,24 +6864,14 @@ def mode_edit_user(phase):
html.write("</ul>")
html.write("</td></tr>")
- languages = get_languages()
- if languages:
- html.write("<tr><td class=legend>")
- html.write(_("Language") + _('<br><i>Configure the
default language '
- 'to be used in the multisite GUI.</i>'))
- html.write("</td><td class=content>")
- default_label = _('Default (%s)') % config.default_language
- languages = [ ('', default_label) ] + languages
- html.select("language", languages, config.get_language(default_label))
- html.write("</td></tr>")
-
+ select_language(user.get('language', ''))
# TODO: Later we could add custom macros here, which
# then could be used for notifications. On the other hand,
# if we implement some check_mk --notify, we could directly
# access the data in the account with the need to store
# values in the monitoring core. We'll see what future brings.
- html.write("<tr><td class=buttons colspan=2>")
+ html.write("<tr><td class=buttons colspan=3>")
html.button("save", _("Save"))
html.write("</tr>")
@@ -9108,6 +9101,25 @@ def register_rule(group, varname, valuespec = None, title = None,
# The user can edit the own profile
#
+def select_language(user_language):
+ languages = get_languages()
+ inactive = user_language != ''
+
+ if languages:
+ html.write("<tr><td class=legend>")
+ html.write(_("Language") + _('<br><i>Configure the
default language '
+ 'to be used in the multisite GUI.</i>'))
+ html.write("</td><td class=checkbox>")
+ html.checkbox('_set_lang', inactive, onclick =
'wato_toggle_attribute(this, \'language\')')
+ html.write("</td><td class=content>")
+ default_label = _('Default: %s') %
(get_language_alias(config.default_language) or _('English'))
+ html.write('<div class="inherited"
id="attr_default_language" style="%s">%s</div>' %
+ (inactive and "display: none" or
"", default_label))
+ html.write('<div id="attr_entry_language"
style="%s">' % ((not inactive) and "display: none" or
""))
+ html.select("language", languages, user_language)
+ html.set_focus("lang")
+ html.write("</div></td></tr>")
+
def page_user_profile():
if not config.user_id:
raise MKUserError(None, _('Not logged in.'))
@@ -9125,7 +9137,9 @@ def page_user_profile():
set_lang = html.var('_set_lang')
language = html.var('language')
# Set the users language if requested
- if set_lang and language and language != config.get_language():
+ if set_lang and language != config.get_language():
+ if language == '':
+ language = None
# Set custom language
users[config.user_id]['language'] = language
config.user['language'] = language
@@ -9183,23 +9197,7 @@ def page_user_profile():
html.write("</td></tr>")
if config.may('edit_profile'):
- languages = get_languages()
- user_language = config.get_language('')
- active = bool(user_language)
-
- if languages:
- html.write("<tr><td class=legend>")
- html.write(_("Language"))
- html.write("</td><td class=checkbox>")
- html.checkbox('_set_lang', active, onclick =
'wato_toggle_attribute(this, \'language\')')
- html.write("</td><td class=content>")
- default_label = _('Default: %s') %
(get_language_alias(config.default_language) or _('English'))
- html.write('<div class="inherited"
id="attr_default_language" style="%s">%s</div>' %
- (active and "display: none" or
"", default_label))
- html.write('<div id="attr_entry_language"
style="%s">' % ((not active) and "display: none" or
""))
- html.select("language", languages, user_language)
- html.set_focus("lang")
- html.write("</div></td></tr>")
+ select_language(config.get_language(''))
if config.may('change_password'):
html.write("<tr><td class=legend colspan=2>")