[checkmk-commits] Check_MK Git: check_mk: #2010 FIX Improved error message when trying to add group assignment rule without having a group configured

Lars Michelsen lm at mathias-kettner.de
Fri Feb 20 14:14:07 CET 2015


Module: check_mk
Branch: master
Commit: ee96526834dacc9f3d291c1ac8c57a5bf4b19deb
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ee96526834dacc9f3d291c1ac8c57a5bf4b19deb

Author: Lars Michelsen <lm at mathias-kettner.de>
Date:   Fri Feb 20 14:09:01 2015 +0100

#2010 FIX Improved error message when trying to add group assignment rule without having a group configured

---

 .werks/2010             |    9 +++++++++
 ChangeLog               |    1 +
 web/htdocs/valuespec.py |    6 +++---
 web/htdocs/wato.py      |    3 +++
 4 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/.werks/2010 b/.werks/2010
new file mode 100644
index 0000000..6e638e9
--- /dev/null
+++ b/.werks/2010
@@ -0,0 +1,9 @@
+Title: Improved error message when trying to add group assignment rule without having a group configured
+Level: 1
+Component: wato
+Compatible: compat
+Version: 1.2.7i1
+Date: 1424437663
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index 92e3c3c..3b69866 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -243,6 +243,7 @@
     * 1987 FIX: Editing auxtags shows existing topics in dropdown instead of as "create new topic"
     * 2001 FIX: Fix exception of missing .site when editing a non-existing host
     * 2009 FIX: Fixed styling of site login page for establishing a distributed monitoring WATO sync...
+    * 2010 FIX: Improved error message when trying to add group assignment rule without having a group configured
 
     Notifications:
     * 1662 notification plugin spectrum: finalized script. now able to handle host notications
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index f486bc2..14200ff 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -2930,6 +2930,7 @@ class ElementSelection(ValueSpec):
         ValueSpec.__init__(self, **kwargs)
         self._loaded_at = None
         self._label = kwargs.get("label")
+        self._empty_text = kwargs.get("empty_text", _("There are not defined any elements for this selection yet."))
 
     def load_elements(self):
         if self._loaded_at != id(html):
@@ -2944,7 +2945,7 @@ class ElementSelection(ValueSpec):
     def render_input(self, varprefix, value):
         self.load_elements()
         if len(self._elements) == 0:
-            html.write(_("There are not defined any elements for this selection yet."))
+            html.write(self._empty_text)
         else:
             if self._label:
                 html.write("%s " % self._label)
@@ -2960,8 +2961,7 @@ class ElementSelection(ValueSpec):
     def validate_value(self, value, varprefix):
         self.load_elements()
         if len(self._elements) == 0:
-            raise MKUserError(varprefix,
-              _("You cannot save this rule. There are not defined any elements for this selection yet."))
+            raise MKUserError(varprefix, _("You cannot save this rule.") + ' ' + self._empty_text)
         if value not in self._elements:
             raise MKUserError(varprefix, _("%s is not an existing element in this selection.") % (value,))
         ValueSpec.custom_validate(self, value, varprefix)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 6a8ee20..ace5385 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -8112,6 +8112,9 @@ def save_group_information(all_groups):
 
 class GroupSelection(ElementSelection):
     def __init__(self, what, **kwargs):
+        kwargs.setdefault('empty_text', _('You have not defined any %s group yet. Please '
+                                          '<a href="wato.py?mode=edit_%s_group">create</a> at least one first.') %
+                                                                                                    (what, what))
         ElementSelection.__init__(self, **kwargs)
         self._what = what
         # Allow to have "none" entry with the following title



More information about the checkmk-commits mailing list