Module: check_mk
Branch: master
Commit: 2728b24e475394e80de2368eb3b451dfbcae59bb
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2728b24e475394…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Mar 9 09:07:08 2017 +0100
CME: Users can now be assigned with customers
Change-Id: I63397b111982a21853f275ee7f817550ed56ae8a
---
web/htdocs/wato.py | 20 ++++++++++++++++++
web/plugins/wato/check_mk_configuration.py | 33 +++++++++++++++++++++---------
2 files changed, 43 insertions(+), 10 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 514e047..887a726 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -10246,6 +10246,9 @@ def mode_users(phase):
else:
html.write_text(_("Never logged in"))
+ if cmk.is_managed_edition():
+ table.cell(_("Customer"), managed.get_customer_name(user))
+
# Connection
if connection:
table.cell(_("Connection"), '%s (%s)' %
(connection.short_title(), user_connection_id))
@@ -10421,6 +10424,9 @@ def mode_edit_user(phase):
timeperiods = load_timeperiods()
roles = userdb.load_roles()
+ if cmk.is_managed_edition():
+ vs_customer = managed.vs_customer()
+
if phase == "action":
if not html.check_transaction():
return "users"
@@ -10494,6 +10500,13 @@ def mode_edit_user(phase):
# Pager
user_attrs["pager"] = html.var("pager", '').strip()
+ if cmk.is_managed_edition():
+ customer = vs_customer.from_html_vars("customer")
+ vs_customer.validate_value(value, "customer")
+
+ if customer != "provider":
+ user_attrs["customer"] = customer
+
# Roles
user_attrs["roles"] = filter(lambda role:
html.get_checkbox("role_" + role),
roles.keys())
@@ -10591,6 +10604,13 @@ def mode_edit_user(phase):
forms.section(_("Pager address"))
lockable_input('pager', '')
html.help(_("The pager address is optional "))
+
+ if cmk.is_managed_edition():
+ forms.section(vs_customer.title())
+ vs_customer.render_input("customer", managed.get_customer_id(user))
+
+ html.help(vs_customer.help())
+
custom_user_attributes('ident')
forms.header(_("Security"))
diff --git a/web/plugins/wato/check_mk_configuration.py
b/web/plugins/wato/check_mk_configuration.py
index e6c551e..8e8f421 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -26,8 +26,11 @@
import re
+import cmk
import cmk.paths
+import managed
+
# .--Global Settings-----------------------------------------------------.
# | ____ _ _ _ ____ _ _ _ |
# | / ___| | ___ | |__ __ _| | / ___| ___| |_| |_(_)_ __ __ _ ___ |
@@ -1092,16 +1095,16 @@ def list_contactgroups():
entries.sort()
return entries
-register_configvar(group,
- "default_user_profile",
- Dictionary(
- title = _("Default user profile"),
- help = _("With this option you can specify the attributes a user which is
created during "
- "its initial login gets added. For example, the default is to add
the role \"user\" "
- "to all automatically created users."),
- elements = [
+
+def default_user_profile_elements():
+ elements = []
+
+ if cmk.is_managed_edition():
+ elements += managed.customer_choice_element()
+
+ return elements + [
('roles', ListChoice(
- title = _('User Roles'),
+ title = _('User roles'),
help = _('Specify the initial roles of an automatically created
user.'),
default_value = [ 'user' ],
choices = list_roles,
@@ -1112,7 +1115,17 @@ register_configvar(group,
default_value = [],
choices = list_contactgroups,
)),
- ],
+ ]
+
+
+register_configvar(group,
+ "default_user_profile",
+ Dictionary(
+ title = _("Default user profile"),
+ help = _("With this option you can specify the attributes a user which is
created during "
+ "its initial login gets added. For example, the default is to add
the role \"user\" "
+ "to all automatically created users."),
+ elements = default_user_profile_elements,
optional_keys = [],
),
domain = "multisite",