Module: check_mk
Branch: master
Commit: de1a09987dadbaa1d606d28d1b7b16681f5a1836
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=de1a09987dadba…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed May 2 18:13:58 2012 +0200
WATO: timeperiod: fix deletion of one day
---
web/htdocs/wato.py | 17 ++++++++---------
1 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index ec73dc6..9605bc8 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -5706,7 +5706,7 @@ class MultipleTimeRanges(ValueSpec):
for c in range(0, self._num_columns):
if c:
html.write(" ")
- if len(value) >= c:
+ if c < len(value):
v = value[c]
else:
v = self._rangevs.canonical_value()
@@ -5750,16 +5750,13 @@ def mode_edit_timeperiod(phase):
def convert_to_range(value):
return tuple(map(convert_to_tod, value))
- def timeperiod_ranges(vp, keyname):
+ def timeperiod_ranges(vp, keyname, new):
ranges = timeperiod.get(keyname, [])
value = []
for range in ranges:
value.append(convert_from_range(range))
- while len(value) < num_columns:
- if len(value) == 0 and new:
- value.append(((0,0),(24,0)))
- else:
- value.append(None)
+ if len(value) == 0 and new:
+ value.append(((0,0),(24,0)))
html.write("<td>")
MultipleTimeRanges().render_input(vp, value)
@@ -5811,6 +5808,8 @@ def mode_edit_timeperiod(phase):
ranges = get_ranges(weekday)
if ranges:
timeperiod[weekday] = ranges
+ elif weekday in timeperiod:
+ del timeperiod[weekday]
# extract ranges for custom days
for e in range(0, num_exceptions):
@@ -5883,7 +5882,7 @@ def mode_edit_timeperiod(phase):
for weekday, weekday_alias in weekdays:
ranges = timeperiod.get(weekday)
html.write("<tr><td class=name>%s</td>" %
weekday_alias)
- timeperiod_ranges(weekday, weekday)
+ timeperiod_ranges(weekday, weekday, new)
html.write("</tr>")
html.write("</table></td></tr>")
@@ -5913,7 +5912,7 @@ def mode_edit_timeperiod(phase):
html.write("<tr><td class=name>")
html.text_input(varprefix + "_name", exname)
html.write("</td>")
- timeperiod_ranges(varprefix, exname)
+ timeperiod_ranges(varprefix, exname, False)
html.write("</tr>")
html.write("</table></td></tr>")