button in views when no downtimes to be deleted
Message-ID: <50e6cf2c.rvCsRx2apPz6Fx2f%lm(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.4 7/29/08
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: 84cd77327d6e8dd9a1dd78eecf890560cdff037a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=84cd77327d6e8d…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jan 4 09:43:35 2013 +0100
FIX: Fixed "remove all downtimes" button in views when no downtimes to be
deleted
---
.bugs/662 | 9 +++++++--
ChangeLog | 1 +
web/htdocs/views.py | 13 ++++++++++---
web/plugins/views/commands.py | 1 +
4 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/.bugs/662 b/.bugs/662
index 850773b..ab19dce 100644
--- a/.bugs/662
+++ b/.bugs/662
@@ -1,9 +1,9 @@
Title: "Remove All" downtimes command button selection problem
Component: multisite
-State: open
+Class: bug
+State: done
Date: 2012-10-26 10:55:14
Targetversion: 1.2.0
-Class: bug
Set a downtime for multiple services within a view
@@ -11,3 +11,8 @@ Try to remove these downtimes with the "Remove all" button,
but additionally sel
downtime set -> Shows error "Sorry. This function is not implemented"
Select exactly the services in downtime and press "Remove all" -> working
+
+2013-01-04 09:42:59: changed state open -> done
+Has been changed to work even if there was no downtime available to delete. The
"success" message shows
+up a note "no data row", means no downtime has been deleted. But this is no
error message, since the
+result is as expected: No downtimes (anymore).
diff --git a/ChangeLog b/ChangeLog
index d0f941d..6ae1cc0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -77,6 +77,7 @@
* Views: Commands/Checkboxes buttons are now activated dynamically (depending on data
displayed)
* FIX: Views: toggling forms does not disable the checkbox button anymore
* FIX: Dashboard: Fixed wrong display options in links after data reloads
+ * FIX: Fixed "remove all downtimes" button in views when no downtimes to be
deleted
WATO:
* FIX: Fixed generated manual check definitions for checks without items
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 615604e..04ad94f 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -2126,7 +2126,10 @@ def core_command(what, row):
commands, title = result
break
- if not commands:
+ # Use the title attribute to determine if a command exists, since the list
+ # of commands might be empty (e.g. in case of "remove all downtimes"
where)
+ # no downtime exists in a selection of rows.
+ if not title:
raise MKUserError(None, _("Sorry. This command is not implemented."))
# Some commands return lists of commands, others
@@ -2176,15 +2179,19 @@ def do_actions(view, what, action_rows, backurl):
executor(command, row["site"])
count += 1
+ message = None
if command:
message = _("Successfully sent %d commands.") % count
if config.debug:
message += _("The last one was: <pre>%s</pre>") %
command
+ elif count == 0:
+ message = _("No matching data row. No command sent.")
+
+ if message:
if html.output_format == "html": # sorry for this hack
message += '<br><a href="%s">%s</a>' %
(backurl, _('Back to view'))
html.message(message)
- elif count == 0:
- html.message(_("No matching data row. No command sent."))
+
return True
def get_selected_rows(view, rows, sel_var):
diff --git a/web/plugins/views/commands.py b/web/plugins/views/commands.py
index a9b4998..3bb02e3 100644
--- a/web/plugins/views/commands.py
+++ b/web/plugins/views/commands.py
@@ -367,6 +367,7 @@ def command_downtime(cmdtag, spec, row):
for id in row[prefix + "downtimes"]:
if id != "":
downtime_ids.append(int(id))
+
commands = []
for dtid in downtime_ids:
commands.append("DEL_%s_DOWNTIME;%d\n" % (cmdtag, dtid))