Moved GPCFieldRenderer to products module.

This commit is contained in:
Lance Edgar 2013-08-17 08:36:17 -07:00
parent 6b1d1c3336
commit dc44bbac67
2 changed files with 16 additions and 18 deletions

View file

@ -34,11 +34,8 @@ import formalchemy
from edbob.pyramid.forms import pretty_datetime from edbob.pyramid.forms import pretty_datetime
from edbob.pyramid.forms.formalchemy.renderers import YesNoFieldRenderer from edbob.pyramid.forms.formalchemy.renderers import YesNoFieldRenderer
import rattail
from rattail.gpc import GPC
from .common import AutocompleteFieldRenderer, EnumFieldRenderer from .common import AutocompleteFieldRenderer, EnumFieldRenderer
from .products import ProductFieldRenderer from .products import GPCFieldRenderer, ProductFieldRenderer
from .users import UserFieldRenderer from .users import UserFieldRenderer
@ -47,17 +44,6 @@ __all__ = ['AutocompleteFieldRenderer', 'EnumFieldRenderer', 'YesNoFieldRenderer
'PriceWithExpirationFieldRenderer', 'ProductFieldRenderer', 'UserFieldRenderer'] 'PriceWithExpirationFieldRenderer', 'ProductFieldRenderer', 'UserFieldRenderer']
class GPCFieldRenderer(formalchemy.TextFieldRenderer):
"""
Renderer for :class:`rattail.gpc.GPC` fields.
"""
@property
def length(self):
# Hm, should maybe consider hard-coding this...?
return len(str(GPC(0)))
def PersonFieldRenderer(url): def PersonFieldRenderer(url):
BaseRenderer = AutocompleteFieldRenderer(url) BaseRenderer = AutocompleteFieldRenderer(url)

View file

@ -26,15 +26,27 @@
``rattail.pyramid.forms.renderers.products`` -- Product Field Renderers ``rattail.pyramid.forms.renderers.products`` -- Product Field Renderers
""" """
from formalchemy.fields import TextFieldRenderer from formalchemy import TextFieldRenderer
from rattail.gpc import GPC
__all__ = ['ProductFieldRenderer'] __all__ = ['GPCFieldRenderer', 'ProductFieldRenderer']
class GPCFieldRenderer(TextFieldRenderer):
"""
Renderer for :class:`rattail.gpc.GPC` fields.
"""
@property
def length(self):
# Hm, should maybe consider hard-coding this...?
return len(str(GPC(0)))
class ProductFieldRenderer(TextFieldRenderer): class ProductFieldRenderer(TextFieldRenderer):
""" """
Renderer for fields which represent ``Product`` instances. Renderer for fields which represent :class:`rattail.db.Product` instances.
""" """
def render_readonly(self, **kwargs): def render_readonly(self, **kwargs):