diff roundup/cgi/templating.py @ 4842:1e4c45a4254b

Allow using plain() on unsaved dates in HTML forms copy_url and history want to display the local time of DateHTMLProperty values, using the plain() method. When the value has not been saved (e.g. when saving was not possibile due to an error in a different entry field), it is just a string, so it does not have a local() method.
author Thomas Arendsen Hein <thomas@intevation.de>
date Tue, 22 Oct 2013 16:20:42 +0200
parents c317147fd891
children 3e36a3bc0335
line wrap: on
line diff
--- a/roundup/cgi/templating.py	Mon Oct 21 12:56:28 2013 +0200
+++ b/roundup/cgi/templating.py	Tue Oct 22 16:20:42 2013 +0200
@@ -1704,7 +1704,11 @@
             offset = self._db.getUserTimezone()
         else:
             offset = self._offset
-        return str(self._value.local(offset))
+        try:
+            return str(self._value.local(offset))
+        except AttributeError:
+            # not a date value, e.g. from unsaved form data
+            return str(self._value)
 
     def now(self, str_interval=None):
         """ Return the current time.

Roundup Issue Tracker: http://roundup-tracker.org/