Tweak some customer view/field rendering, to allow more customization
This commit is contained in:
parent
56695d0c20
commit
eb272bf7f9
|
@ -1,8 +1,8 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8; -*-
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2016 Lance Edgar
|
# Copyright © 2010-2017 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -26,6 +26,7 @@ People Field Renderers
|
||||||
|
|
||||||
from __future__ import unicode_literals, absolute_import
|
from __future__ import unicode_literals, absolute_import
|
||||||
|
|
||||||
|
import six
|
||||||
from webhelpers.html import tags
|
from webhelpers.html import tags
|
||||||
|
|
||||||
from tailbone.forms.renderers.common import AutocompleteFieldRenderer
|
from tailbone.forms.renderers.common import AutocompleteFieldRenderer
|
||||||
|
@ -55,4 +56,8 @@ class CustomerFieldRenderer(AutocompleteFieldRenderer):
|
||||||
customer = self.raw_value
|
customer = self.raw_value
|
||||||
if not customer:
|
if not customer:
|
||||||
return ''
|
return ''
|
||||||
return tags.link_to(customer, self.request.route_url('customers.view', uuid=customer.uuid))
|
text = self.render_value(customer)
|
||||||
|
return tags.link_to(text, self.request.route_url('customers.view', uuid=customer.uuid))
|
||||||
|
|
||||||
|
def render_value(self, customer):
|
||||||
|
return six.text_type(customer)
|
||||||
|
|
|
@ -47,8 +47,7 @@ class CustomersView(MasterView):
|
||||||
model_class = model.Customer
|
model_class = model.Customer
|
||||||
supports_mobile = True
|
supports_mobile = True
|
||||||
|
|
||||||
def configure_grid(self, g):
|
def _preconfigure_grid(self, g):
|
||||||
|
|
||||||
g.joiners['email'] = lambda q: q.outerjoin(model.CustomerEmailAddress, sa.and_(
|
g.joiners['email'] = lambda q: q.outerjoin(model.CustomerEmailAddress, sa.and_(
|
||||||
model.CustomerEmailAddress.parent_uuid == model.Customer.uuid,
|
model.CustomerEmailAddress.parent_uuid == model.Customer.uuid,
|
||||||
model.CustomerEmailAddress.preference == 1))
|
model.CustomerEmailAddress.preference == 1))
|
||||||
|
@ -73,9 +72,11 @@ class CustomersView(MasterView):
|
||||||
|
|
||||||
g.default_sortkey = 'name'
|
g.default_sortkey = 'name'
|
||||||
|
|
||||||
|
def configure_grid(self, g):
|
||||||
g.configure(
|
g.configure(
|
||||||
include=[
|
include=[
|
||||||
g.id.label("ID"),
|
g.id.label("ID"),
|
||||||
|
g.number,
|
||||||
g.name,
|
g.name,
|
||||||
g.phone.label("Phone Number"),
|
g.phone.label("Phone Number"),
|
||||||
g.email.label("Email Address"),
|
g.email.label("Email Address"),
|
||||||
|
|
Loading…
Reference in a new issue