Module: check_mk
Branch: master
Commit: df6b2fd8b55d14e2a8194b10f98110af680e9067
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=df6b2fd8b55d14…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Sat Feb 23 21:01:00 2019 +0100
Improved locked host attributes handling
* Attributes are not editable when creating hosts / folders
* Both attributes now display "Not locked" when the object
is currently not locked
Change-Id: I2642e39393ee6472b05e4a98a1f6600f75912531
---
cmk/gui/plugins/wato/builtin_attributes.py | 35 ++++++++++++++++++++----------
cmk/gui/plugins/wato/utils/__init__.py | 2 +-
cmk/gui/watolib/host_attributes.py | 4 ++--
3 files changed, 26 insertions(+), 15 deletions(-)
diff --git a/cmk/gui/plugins/wato/builtin_attributes.py
b/cmk/gui/plugins/wato/builtin_attributes.py
index be3a7c3..76d39f5 100644
--- a/cmk/gui/plugins/wato/builtin_attributes.py
+++ b/cmk/gui/plugins/wato/builtin_attributes.py
@@ -734,23 +734,33 @@ class HostAttributeLockedBy(ABCHostAttributeValueSpec):
def valuespec(self):
return Transform(
- Tuple(
- orientation="horizontal",
- title_br=False,
- elements=[
- SiteChoice(),
- ID(title=_("Program"),),
- ID(title=_("Connection ID"),),
- ],
- title=_("Locked by"),
- help=_("The host is (partially) managed by an automatic data source
like the "
- "Dynamic Configuration."),
- ),
+ LockedByValuespec(),
forth=tuple,
back=list,
)
+class LockedByValuespec(Tuple):
+ def __init__(self):
+ super(LockedByValuespec, self).__init__(
+ orientation="horizontal",
+ title_br=False,
+ elements=[
+ SiteChoice(),
+ ID(title=_("Program"),),
+ ID(title=_("Connection ID"),),
+ ],
+ title=_("Locked by"),
+ help=_("The host is (partially) managed by an automatic data source like
the "
+ "Dynamic Configuration."),
+ )
+
+ def value_to_text(self, value):
+ if not value or not value[1] or not value[2]:
+ return _("Not locked")
+ return super(LockedByValuespec, self).value_to_text(value)
+
+
@host_attribute_registry.register
class HostAttributeLockedAttributes(ABCHostAttributeValueSpec):
def name(self):
@@ -781,4 +791,5 @@ class HostAttributeLockedAttributes(ABCHostAttributeValueSpec):
return ListOf(
DropdownChoice(choices=host_attribute_registry.get_choices),
title=_("Locked attributes"),
+ text_if_empty=_("Not locked"),
)
diff --git a/cmk/gui/plugins/wato/utils/__init__.py
b/cmk/gui/plugins/wato/utils/__init__.py
index e8ff0fb..40cc792 100644
--- a/cmk/gui/plugins/wato/utils/__init__.py
+++ b/cmk/gui/plugins/wato/utils/__init__.py
@@ -1563,7 +1563,7 @@ def configure_attributes(new,
if for_what == "host_search":
is_editable = True
- if not new and not is_editable:
+ if not is_editable:
# Bug in pylint 1.9.2
https://github.com/PyCQA/pylint/issues/1984,
already fixed in master.
if active: # pylint: disable=simplifiable-if-statement
force_entry = True
diff --git a/cmk/gui/watolib/host_attributes.py b/cmk/gui/watolib/host_attributes.py
index b331caa..9f1db5a 100644
--- a/cmk/gui/watolib/host_attributes.py
+++ b/cmk/gui/watolib/host_attributes.py
@@ -277,8 +277,8 @@ class ABCHostAttribute(object):
def editable(self):
# type: () -> bool
- """Whether or not this attribute can be edited after creation
- of the object"""
+ """Whether or not this attribute can be edited using the GUI.
+ This makes the attribute a read only attribute in the GUI."""
return True
def is_mandatory(self):