3
0
Fork 0

fix: use span element for readonly money field widget render

This commit is contained in:
Lance Edgar 2024-12-28 21:18:10 -06:00
parent 84ab931081
commit 6515a0a224
2 changed files with 4 additions and 4 deletions

View file

@ -224,9 +224,9 @@ class WuttaMoneyInputWidget(MoneyInputWidget):
readonly = kw.get('readonly', self.readonly) readonly = kw.get('readonly', self.readonly)
if readonly: if readonly:
if cstruct in (colander.null, None): if cstruct in (colander.null, None):
return "" return HTML.tag('span')
cstruct = decimal.Decimal(cstruct) cstruct = decimal.Decimal(cstruct)
return self.app.render_currency(cstruct) return HTML.tag('span', c=[self.app.render_currency(cstruct)])
return super().serialize(field, cstruct, **kw) return super().serialize(field, cstruct, **kw)

View file

@ -131,11 +131,11 @@ class TestWuttaMoneyInputWidget(WebTestCase):
# readonly is rendered per app convention # readonly is rendered per app convention
result = widget.serialize(field, str(amount), readonly=True) result = widget.serialize(field, str(amount), readonly=True)
self.assertEqual(result, '$12.34') self.assertEqual(result, '<span>$12.34</span>')
# readonly w/ null value # readonly w/ null value
result = widget.serialize(field, None, readonly=True) result = widget.serialize(field, None, readonly=True)
self.assertEqual(result, '') self.assertEqual(result, '<span></span>')
class TestFileDownloadWidget(WebTestCase): class TestFileDownloadWidget(WebTestCase):