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
|
||||
# Copyright © 2010-2016 Lance Edgar
|
||||
# Copyright © 2010-2017 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -26,6 +26,7 @@ People Field Renderers
|
|||
|
||||
from __future__ import unicode_literals, absolute_import
|
||||
|
||||
import six
|
||||
from webhelpers.html import tags
|
||||
|
||||
from tailbone.forms.renderers.common import AutocompleteFieldRenderer
|
||||
|
@ -55,4 +56,8 @@ class CustomerFieldRenderer(AutocompleteFieldRenderer):
|
|||
customer = self.raw_value
|
||||
if not customer:
|
||||
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
|
||||
supports_mobile = True
|
||||
|
||||
def configure_grid(self, g):
|
||||
|
||||
def _preconfigure_grid(self, g):
|
||||
g.joiners['email'] = lambda q: q.outerjoin(model.CustomerEmailAddress, sa.and_(
|
||||
model.CustomerEmailAddress.parent_uuid == model.Customer.uuid,
|
||||
model.CustomerEmailAddress.preference == 1))
|
||||
|
@ -73,9 +72,11 @@ class CustomersView(MasterView):
|
|||
|
||||
g.default_sortkey = 'name'
|
||||
|
||||
def configure_grid(self, g):
|
||||
g.configure(
|
||||
include=[
|
||||
g.id.label("ID"),
|
||||
g.number,
|
||||
g.name,
|
||||
g.phone.label("Phone Number"),
|
||||
g.email.label("Email Address"),
|
||||
|
|
Loading…
Reference in a new issue