Module: check_mk
Branch: master
Commit: 7a9899dc4acab8a1448570cf3eb08acfbc5367b1
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7a9899dc4acab8…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sun Oct 5 15:47:46 2014 +0200
Extra new valuespec DateFormat from views/painters.py
This new valuespec can now be used at other places as well.
---
web/htdocs/valuespec.py | 15 +++++++++++++++
web/plugins/views/painters.py | 12 +-----------
2 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 25e0437..a06e48a 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -2114,6 +2114,21 @@ class PNPTimerange(Timerange):
Timerange.__init__(self, **kwargs)
+# A selection of various date formats
+def DateFormat(**args):
+ args.setdefault("title", _("Date format"))
+ args.setdefault("default_value", "%Y-%m-%d")
+ args["choices"] = [
+ ("%Y-%m-%d", "1970-12-18"),
+ ("%d.%m.%Y", "18.12.1970"),
+ ("%m/%d/%Y", "12/18/1970"),
+ ("%d.%m.", "18.12."),
+ ("%m/%d", "12/18"),
+ ]
+ return DropdownChoice(**args)
+
+
+
# Make a configuration value optional, i.e. it may be None.
# The user has a checkbox for activating the option. Example:
# debug_log: it is either None or set to a filename.
diff --git a/web/plugins/views/painters.py b/web/plugins/views/painters.py
index dd0daa5..6033075 100644
--- a/web/plugins/views/painters.py
+++ b/web/plugins/views/painters.py
@@ -97,17 +97,7 @@ multisite_painter_options["ts_format"] = {
}
multisite_painter_options["ts_date"] = {
- 'valuespec' : DropdownChoice(
- title = _("Date format"),
- default_value = "%Y-%m-%d",
- choices = [
- ("%Y-%m-%d", "1970-12-18"),
- ("%d.%m.%Y", "18.12.1970"),
- ("%m/%d/%Y", "12/18/1970"),
- ("%d.%m.", "18.12."),
- ("%m/%d", "12/18")
- ],
- )
+ 'valuespec' : DateFormat(),
}
# This helper function returns the value of the given custom var