changeset 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 3ff1a288fb9c
children 55d1a73d6118
files CHANGES.txt roundup/cgi/templating.py
diffstat 2 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES.txt	Mon Oct 21 12:56:28 2013 +0200
+++ b/CHANGES.txt	Tue Oct 22 16:20:42 2013 +0200
@@ -28,6 +28,8 @@
   handle multilink properties. (John Rouillard)
 - issue2550583, issue2550635 Do not limit results with Xapian indexer
   (Thomas Arendsen Hein)
+- Allow using plain() on unsaved dates in HTML forms
+  (Thomas Arendsen Hein)
 
 2013-07-06: 1.5.0
 
--- 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/