Module: check_mk
Branch: master
Commit: db9f18c06d7ac20dcb1a5ba53af43546c49e9273
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=db9f18c06d7ac2…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sat Jan 21 21:38:38 2012 +0100
ValueSpec: fixed in RelativeDate and Alternative
---
web/htdocs/valuespec.py | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 5067b51..fc547ad 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -753,7 +753,6 @@ weekdays = {
}
class RelativeDate(OptionalDropdownChoice):
-
def __init__(self, **kwargs):
ValueSpec.__init__(self, **kwargs)
self._choices = [
@@ -772,10 +771,13 @@ class RelativeDate(OptionalDropdownChoice):
self._choices.append((w + 7, weekdays[wd] + title))
self._explicit = Integer()
self._otherlabel = _("in ... days")
-
+ if "default_days" in kwargs:
+ self._default_value = kwargs["default_days"] * seconds_per_day +
today()
+ else:
+ self._default_value = today()
def canonical_value(self):
- return today()
+ return self._default_value
def render_input(self, varprefix, value):
reldays = (round_date(value) - today()) / seconds_per_day
@@ -907,14 +909,17 @@ class Alternative(ValueSpec):
else:
checked = vs == mvs
- html.radiobutton(varprefix + "_use", str(nr), checked, vs.title())
- html.write("<ul>")
+ title = vs.title()
+ html.radiobutton(varprefix + "_use", str(nr), checked, title)
+ if title:
+ html.write("<ul>")
if vs == mvs:
val = value
else:
val = vs.canonical_value()
vs.render_input(varprefix + "_%d" % nr, val)
- html.write("</ul>\n")
+ if title:
+ html.write("</ul>\n")
def set_focus(self, varprefix):
# TODO: Set focus to currently active option