Add QuantityFieldRenderer
This commit is contained in:
parent
4c929055e6
commit
aa99f3b506
|
@ -29,7 +29,7 @@ from __future__ import unicode_literals, absolute_import
|
||||||
from .core import CustomFieldRenderer, DateFieldRenderer
|
from .core import CustomFieldRenderer, DateFieldRenderer
|
||||||
|
|
||||||
from .common import (StrippedTextFieldRenderer, CodeTextAreaFieldRenderer, AutocompleteFieldRenderer,
|
from .common import (StrippedTextFieldRenderer, CodeTextAreaFieldRenderer, AutocompleteFieldRenderer,
|
||||||
DecimalFieldRenderer, CurrencyFieldRenderer,
|
DecimalFieldRenderer, CurrencyFieldRenderer, QuantityFieldRenderer,
|
||||||
DateTimeFieldRenderer, DateTimePrettyFieldRenderer, TimeFieldRenderer,
|
DateTimeFieldRenderer, DateTimePrettyFieldRenderer, TimeFieldRenderer,
|
||||||
EnumFieldRenderer, YesNoFieldRenderer)
|
EnumFieldRenderer, YesNoFieldRenderer)
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ from __future__ import unicode_literals, absolute_import
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from rattail.time import localtime, make_utc
|
from rattail.time import localtime, make_utc
|
||||||
|
from rattail.util import pretty_quantity
|
||||||
|
|
||||||
import formalchemy as fa
|
import formalchemy as fa
|
||||||
from formalchemy import fields as fa_fields, helpers as fa_helpers
|
from formalchemy import fields as fa_fields, helpers as fa_helpers
|
||||||
|
@ -248,6 +249,15 @@ class CurrencyFieldRenderer(fa_fields.FloatFieldRenderer):
|
||||||
return "${:0,.2f}".format(value)
|
return "${:0,.2f}".format(value)
|
||||||
|
|
||||||
|
|
||||||
|
class QuantityFieldRenderer(fa_fields.FloatFieldRenderer):
|
||||||
|
"""
|
||||||
|
Sort of generic field renderer for quantity values.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def render_readonly(self, **kwargs):
|
||||||
|
return pretty_quantity(self.raw_value)
|
||||||
|
|
||||||
|
|
||||||
class YesNoFieldRenderer(fa.CheckBoxFieldRenderer):
|
class YesNoFieldRenderer(fa.CheckBoxFieldRenderer):
|
||||||
|
|
||||||
def render_readonly(self, **kwargs):
|
def render_readonly(self, **kwargs):
|
||||||
|
|
Loading…
Reference in a new issue