Module: check_mk
Branch: master
Commit: b673ffc6d49c8564dc95a84994d800d1e32d9349
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b673ffc6d49c85…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Jan 18 10:51:05 2016 +0100
WATO BI: prevent deletion of rules that are in use
The delete button was already correctly removed in that case,
we just address the rare case of URI modifications or race
conditions
---
web/plugins/wato/bi.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/web/plugins/wato/bi.py b/web/plugins/wato/bi.py
index add024d..e512195 100644
--- a/web/plugins/wato/bi.py
+++ b/web/plugins/wato/bi.py
@@ -1061,6 +1061,11 @@ class ModeBIRules(ModeBI):
self.must_be_contact_for_pack()
if html.var("_del_rule"):
ruleid = html.var("_del_rule")
+ aggr_refs, rule_refs, level = self.count_rule_references(ruleid)
+ if aggr_refs:
+ raise MKUserError(None, _("You cannot delete this rule: it is still
used by aggregations."))
+ if rule_refs:
+ raise MKUserError(None, _("You cannot delete this rule: it is still
used by other rules."))
c = wato_confirm(_("Confirm rule deletion"),
_("Do you really want to delete the rule with "
"the id <b>%s</b>?") % ruleid)
@@ -1112,7 +1117,7 @@ class ModeBIRules(ModeBI):
tree_url = html.makeuri([("mode",
"bi_rule_tree"), ("id", ruleid)])
html.icon_button(tree_url, _("This is a top-level rule. Show
rule tree"), "bitree")
if refs == 0:
- delete_url = html.makeactionuri([("mode",
"bi_rules"), ("_del_rule", ruleid)])
+ delete_url = html.makeactionuri_contextless([("mode",
"bi_rules"), ("_del_rule", ruleid), ("pack",
self._pack_id)])
html.icon_button(delete_url, _("Delete this rule"),
"delete")
table.cell(_("Level"), level or "",
css="number")
table.cell(_("ID"), '<a
href="%s">%s</a>' % (edit_url, ruleid))