changeset 1463:fc55b35066ee

Add DateTime widget for the metadata editor.
author Pavel Sviderski <pavel@psviderski.name>
date Sun, 29 Jul 2012 22:43:25 +0200
parents 20ff5996c3a6
children 89a6cda81ffe
files MoinMoin/constants/forms.py MoinMoin/forms.py MoinMoin/templates/forms.html
diffstat 3 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/constants/forms.py	Sun Jul 29 20:21:44 2012 +0200
+++ b/MoinMoin/constants/forms.py	Sun Jul 29 22:43:25 2012 +0200
@@ -16,6 +16,7 @@
 WIDGET_INLINE_CHECKBOX = u'inline_checkbox'
 WIDGET_ANY_INTEGER = u'any_integer'
 WIDGET_SMALL_NATURAL = u'small_natural'
+WIDGET_DATETIME = u'datetime'
 
 WIDGET_FILE = u'file'
 WIDGET_SEARCH = u'search'
--- a/MoinMoin/forms.py	Sun Jul 29 20:21:44 2012 +0200
+++ b/MoinMoin/forms.py	Sun Jul 29 22:43:25 2012 +0200
@@ -1,3 +1,4 @@
+# Copyright: 2012 MoinMoin:PavelSviderski
 # Copyright: 2012 MoinMoin:CheerXiao
 # License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
 
@@ -10,7 +11,7 @@
 
 import re
 
-from flatland import Element, Form, String, Integer, Boolean, Enum, Dict, JoinedString
+from flatland import Element, Form, String, Integer, Boolean, Enum, Dict, DateTime as _DateTime, JoinedString
 from flatland.validation import Validator, Present, IsEmail, ValueBetween, URLValidator, Converted, ValueAtLeast
 
 from MoinMoin.constants.forms import *
@@ -64,6 +65,9 @@
 
 SmallNatural = _Integer.with_properties(widget=WIDGET_SMALL_NATURAL)
 
+DateTime = (_DateTime.with_properties(widget=WIDGET_DATETIME, placeholder=_("YYYY-MM-DD HH:MM:SS (example: 2999-12-31 23:59:59)"))
+               .validated_by(Converted(incorrect=L_("Please use the following format: YYYY-MM-DD HH:MM:SS"))))
+
 File = FileStorage.with_properties(widget=WIDGET_FILE)
 
 Submit = String.using(default=L_('OK'), optional=True).with_properties(widget=WIDGET_SUBMIT, class_=CLASS_BUTTON)
--- a/MoinMoin/templates/forms.html	Sun Jul 29 20:21:44 2012 +0200
+++ b/MoinMoin/templates/forms.html	Sun Jul 29 22:43:25 2012 +0200
@@ -50,6 +50,7 @@
       'inline_checkbox': inline_checkbox,
       'any_integer': any_integer,
       'small_natural': small_natural,
+      'datetime': datetime,
       'search': search,
       'submit': raw_input,
       'hidden': raw_input,
@@ -131,6 +132,10 @@
     </dd>
 {% endmacro %}
 
+{% macro datetime(field) %}
+  {{ annotated_input(field, 'text') }}
+{% endmacro %}
+
 {% macro search(field) %}
   {{ raw_input(field, id='moin-search-query') }}
 {% endmacro %}