fix: use span element for readonly money field widget render
This commit is contained in:
parent
84ab931081
commit
6515a0a224
|
@ -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)
|
||||||
|
|
||||||
|
|
|
@ -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):
|
||||||
|
|
Loading…
Reference in a new issue