Module: check_mk
Branch: master
Commit: 304905a9d300e18e1b1f752a8be578da9bf28aec
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=304905a9d300e1…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Mar 5 07:33:58 2018 +0100
5878 FIX Fixes sorting of host tag groups
The sorting of the WATO host tags was broken in the 1.5 releases.
Change-Id: I51b63447648986c12123b1a103aad70813f467ed
---
.werks/5878 | 10 ++++++++++
web/htdocs/wato.py | 19 ++++++++++++++-----
2 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/.werks/5878 b/.werks/5878
new file mode 100644
index 0000000..5488573
--- /dev/null
+++ b/.werks/5878
@@ -0,0 +1,10 @@
+Title: Fixes sorting of host tag groups
+Level: 1
+Component: wato
+Compatible: compat
+Edition: cre
+Version: 1.5.0i4
+Date: 1520231638
+Class: fix
+
+The sorting of the WATO host tags was broken in the 1.5 releases.
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 76b4529..47e29c4 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -11802,7 +11802,6 @@ class ModeHostTags(WatoMode, watolib.HosttagsConfiguration):
def __init__(self):
super(ModeHostTags, self).__init__()
self._hosttags, self._auxtags = self._load_hosttags()
- self._effective_tag_groups = watolib.get_effective_tag_groups(self._hosttags)
def title(self):
@@ -11931,11 +11930,13 @@ class ModeHostTags(WatoMode, watolib.HosttagsConfiguration):
empty_text = _("You haven't defined any tag groups
yet."),
searchable = False, sortable = False)
- if not self._effective_tag_groups:
+ effective_tag_groups = self._get_effective_tag_groups()
+
+ if not effective_tag_groups:
table.end()
return
- for nr, entry in enumerate(self._effective_tag_groups):
+ for nr, entry in enumerate(effective_tag_groups):
tag_id, title, choices = entry[:3] # fourth: tag dependency information
topic, title = map(_u, watolib.parse_hosttag_title(title))
table.row()
@@ -11950,11 +11951,14 @@ class ModeHostTags(WatoMode, watolib.HosttagsConfiguration):
else:
html.icon_button(make_action_link([("mode",
"hosttags"), ("_move", str(-nr))]),
_("Move this tag group one position up"),
"up")
- if nr == len(self._effective_tag_groups) - 1:
+
+ if nr == len(effective_tag_groups) - 1 \
+ or watolib.is_builtin_host_tag_group(effective_tag_groups[nr+1][0]):
html.empty_icon_button()
else:
html.icon_button(make_action_link([("mode",
"hosttags"), ("_move", str(nr))]),
_("Move this tag group one position down"),
"down")
+
html.icon_button(edit_url, _("Edit this tag group"),
"edit")
html.icon_button(delete_url, _("Delete this tag group"),
"delete")
@@ -11980,6 +11984,7 @@ class ModeHostTags(WatoMode, watolib.HosttagsConfiguration):
searchable = False)
aux_tags = watolib.get_effective_aux_tags(self._auxtags)
+ effective_tag_groups = self._get_effective_tag_groups()
if not aux_tags:
table.end()
@@ -12001,10 +12006,14 @@ class ModeHostTags(WatoMode, watolib.HosttagsConfiguration):
table.text_cell(_("Title"), _u(title))
table.text_cell(_("Topic"), _u(topic) or '')
table.text_cell(_("Tags using this auxiliary tag"),
- ",
".join(self._get_tags_using_aux_tag(self._effective_tag_groups, tag_id)))
+ ",
".join(self._get_tags_using_aux_tag(effective_tag_groups, tag_id)))
table.end()
+ def _get_effective_tag_groups(self):
+ return watolib.get_effective_tag_groups(self._hosttags)
+
+
def _get_tags_using_aux_tag(self, tag_groups, aux_tag):
used_tags = set()
for tag_def in tag_groups: