Module: check_mk
Branch: master
Commit: a6ffcd7e2c7d45e5c6bf812a4fb63f03c8d8959f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a6ffcd7e2c7d45…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Fri Apr 13 10:41:38 2018 +0200
Fix topics in ModeEditCustomAttr
Change-Id: If051a65944d3a8369b0d488b429b67de150f3716
---
web/htdocs/wato.py | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 7c044da..a40d298 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -15686,6 +15686,10 @@ class ModeEditCustomAttr(WatoMode):
raise NotImplementedError()
@property
+ def _default_topic(self):
+ raise NotImplementedError()
+
+ @property
def _macro_help(self):
raise NotImplementedError()
@@ -15716,8 +15720,7 @@ class ModeEditCustomAttr(WatoMode):
forms.section(_('Topic'))
html.help(_('The attribute is added to this section in the edit
dialog.'))
- # TODO: is deflt set correctly?
- html.dropdown('topic', self._topics,
deflt=self._attr.get('topic', 'personal'))
+ html.dropdown('topic', self._topics,
deflt=self._attr.get('topic', self._default_topic))
forms.section(_('Help Text') + "<sup>*</sup>")
html.help(_('You might want to add some helpful description for the
attribute.'))
@@ -15768,6 +15771,10 @@ class ModeEditCustomUserAttr(ModeEditCustomAttr):
]
@property
+ def _default_topic(self):
+ return 'personal'
+
+ @property
def _macro_help(self):
return _('The attribute can be added to the contact definiton in order to use
it for notifications.')
@@ -15808,11 +15815,16 @@ class ModeEditCustomHostAttr(ModeEditCustomAttr):
@property
def _topics(self):
- topics = list(set([ (a[1], a[1]) for a in watolib.all_host_attributes() if a[1]
!= None ]))
- topics.insert(0, (_("Custom attributes"), _("Custom
attributes")))
+ default = self._default_topic
+ topics = list(set((a[1], a[1]) for a in watolib.all_host_attributes() if a[1] not
in (None, default)))
+ topics.insert(0, (default, default))
return topics
@property
+ def _default_topic(self):
+ return _("Custom attributes")
+
+ @property
def _macro_help(self):
return _("The attribute can be added to the host definition in order to
"
"use it as monitoring macro in different places, for example
"