Skip to content

Commit 936c7ad

Browse files
committed
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.
1 parent 9cc2ed5 commit 936c7ad

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ Fixed:
2828
handle multilink properties. (John Rouillard)
2929
- issue2550583, issue2550635 Do not limit results with Xapian indexer
3030
(Thomas Arendsen Hein)
31+
- Allow using plain() on unsaved dates in HTML forms
32+
(Thomas Arendsen Hein)
3133

3234
2013-07-06: 1.5.0
3335

roundup/cgi/templating.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1704,7 +1704,11 @@ def plain(self, escape=0):
17041704
offset = self._db.getUserTimezone()
17051705
else:
17061706
offset = self._offset
1707-
return str(self._value.local(offset))
1707+
try:
1708+
return str(self._value.local(offset))
1709+
except AttributeError:
1710+
# not a date value, e.g. from unsaved form data
1711+
return str(self._value)
17081712

17091713
def now(self, str_interval=None):
17101714
""" Return the current time.

0 commit comments

Comments
 (0)