changeset 1689:f77870dd132f

Preload PTIME widget with the current datetime.
author Pavel Sviderski <pavel@psviderski.name>
date Wed, 15 Aug 2012 16:41:51 +0200
parents f676a325b974
children 2601f623bdeb
files MoinMoin/forms.py MoinMoin/items/__init__.py
diffstat 2 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/forms.py	Wed Aug 15 16:41:24 2012 +0200
+++ b/MoinMoin/forms.py	Wed Aug 15 16:41:51 2012 +0200
@@ -136,7 +136,7 @@
             dt = utctimestamp(dt)
         return dt
 
-DateTime = (DateTimeUNIX.with_properties(widget=WIDGET_DATETIME, placeholder=_("YYYY-MM-DD HH:MM:SS (example: 2999-12-31 23:59:59)"))
+DateTime = (DateTimeUNIX.with_properties(widget=WIDGET_DATETIME, placeholder=_("YYYY-MM-DD HH:MM:SS (example: 2013-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)
--- a/MoinMoin/items/__init__.py	Wed Aug 15 16:41:24 2012 +0200
+++ b/MoinMoin/items/__init__.py	Wed Aug 15 16:41:51 2012 +0200
@@ -740,6 +740,14 @@
         meta_form = BlogEntryMetaForm
         meta_template = 'modify_blog_entry_meta.html'
 
+    @classmethod
+    def from_item(cls, item):
+        form = super(BlogEntry._ModifyForm, cls).from_item(item)
+        # preload PTIME with the current datetime
+        if not form['meta_form']['ptime']:
+            form['meta_form']['ptime'].set(datetime.utcnow())
+        return form
+
     def do_show(self, revid):
         blog_item_name = self.name.rsplit('/', 1)[0]
         try: