Add CurrencyFieldRenderer
.
Also clean up the subpackage root a little bit.
This commit is contained in:
parent
62784390b0
commit
e79531fda8
|
@ -24,22 +24,19 @@
|
|||
FormAlchemy Field Renderers
|
||||
"""
|
||||
|
||||
from tailbone.forms.renderers.common import (
|
||||
AutocompleteFieldRenderer,
|
||||
from .common import (AutocompleteFieldRenderer,
|
||||
DecimalFieldRenderer, CurrencyFieldRenderer,
|
||||
DateTimeFieldRenderer,
|
||||
DecimalFieldRenderer,
|
||||
EnumFieldRenderer,
|
||||
YesNoFieldRenderer,
|
||||
)
|
||||
EnumFieldRenderer, YesNoFieldRenderer)
|
||||
|
||||
from .people import (
|
||||
PersonFieldRenderer, PersonFieldLinkRenderer,
|
||||
from .people import (PersonFieldRenderer, PersonFieldLinkRenderer,
|
||||
CustomerFieldRenderer, CustomerFieldLinkRenderer,
|
||||
UserFieldRenderer)
|
||||
|
||||
from .employees import EmployeeFieldRenderer
|
||||
|
||||
from tailbone.forms.renderers.products import GPCFieldRenderer
|
||||
from tailbone.forms.renderers.products import *
|
||||
from .products import (ProductFieldRenderer, GPCFieldRenderer,
|
||||
BrandFieldRenderer, VendorFieldRenderer,
|
||||
PriceFieldRenderer, PriceWithExpirationFieldRenderer)
|
||||
|
||||
from tailbone.forms.renderers.stores import StoreFieldRenderer
|
||||
from .stores import StoreFieldRenderer
|
||||
|
|
|
@ -147,6 +147,21 @@ class DecimalFieldRenderer(formalchemy.FieldRenderer):
|
|||
return fmt.format(value)
|
||||
|
||||
|
||||
class CurrencyFieldRenderer(formalchemy.FieldRenderer):
|
||||
"""
|
||||
Sort of generic field renderer for currency values.
|
||||
"""
|
||||
|
||||
def __init__(self, field):
|
||||
super(CurrencyFieldRenderer, self).__init__(field)
|
||||
|
||||
def render_readonly(self, **kwargs):
|
||||
value = self.raw_value
|
||||
if value is None:
|
||||
return ''
|
||||
return '$ {0:0,.2f}'.format(value)
|
||||
|
||||
|
||||
class YesNoFieldRenderer(CheckBoxFieldRenderer):
|
||||
|
||||
def render_readonly(self, **kwargs):
|
||||
|
|
|
@ -34,11 +34,6 @@ from webhelpers.html import literal
|
|||
from tailbone.util import pretty_datetime
|
||||
|
||||
|
||||
__all__ = ['ProductFieldRenderer', 'GPCFieldRenderer',
|
||||
'BrandFieldRenderer', 'VendorFieldRenderer',
|
||||
'PriceFieldRenderer', 'PriceWithExpirationFieldRenderer']
|
||||
|
||||
|
||||
class ProductFieldRenderer(AutocompleteFieldRenderer):
|
||||
"""
|
||||
Renderer for :class:`rattail.db.model.Product` instance fields.
|
||||
|
|
Loading…
Reference in a new issue