Add email filters for CustData grid; allow downloading results
This commit is contained in:
parent
6208a98ad3
commit
5b48c44891
|
@ -42,6 +42,7 @@ class CustomerView(CoreOfficeMasterView):
|
||||||
model_title_plural = "CORE-POS Customers (Legacy)"
|
model_title_plural = "CORE-POS Customers (Legacy)"
|
||||||
url_prefix = '/core-pos/customers'
|
url_prefix = '/core-pos/customers'
|
||||||
route_prefix = 'corepos.customers'
|
route_prefix = 'corepos.customers'
|
||||||
|
results_downloadable = True
|
||||||
|
|
||||||
labels = {
|
labels = {
|
||||||
'id': "ID",
|
'id': "ID",
|
||||||
|
@ -67,6 +68,14 @@ class CustomerView(CoreOfficeMasterView):
|
||||||
'purchases',
|
'purchases',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def query(self, session):
|
||||||
|
query = super(CustomerView, self).query(session)
|
||||||
|
|
||||||
|
query = query.outerjoin(corepos.MemberInfo,
|
||||||
|
corepos.MemberInfo.card_number == corepos.CustData.card_number)
|
||||||
|
|
||||||
|
return query
|
||||||
|
|
||||||
def configure_grid(self, g):
|
def configure_grid(self, g):
|
||||||
super(CustomerView, self).configure_grid(g)
|
super(CustomerView, self).configure_grid(g)
|
||||||
|
|
||||||
|
@ -79,9 +88,12 @@ class CustomerView(CoreOfficeMasterView):
|
||||||
g.filters['last_name'].default_active = True
|
g.filters['last_name'].default_active = True
|
||||||
g.filters['last_name'].default_verb = 'contains'
|
g.filters['last_name'].default_verb = 'contains'
|
||||||
|
|
||||||
g.set_joiner('member_type', lambda q: q.outerjoin(corepos.MemberType))
|
g.set_joiner('member_type_description', lambda q: q.outerjoin(corepos.MemberType))
|
||||||
g.set_sorter('member_type', corepos.MemberType.description)
|
g.set_sorter('member_type_description', corepos.MemberType.description)
|
||||||
g.set_filter('member_type', corepos.MemberType.description)
|
g.set_filter('member_type_description', corepos.MemberType.description)
|
||||||
|
|
||||||
|
g.set_filter('member_info_email', corepos.MemberInfo.email)
|
||||||
|
g.set_filter('member_info_email2', corepos.MemberInfo.email2)
|
||||||
|
|
||||||
g.set_type('charge_limit', 'currency')
|
g.set_type('charge_limit', 'currency')
|
||||||
g.set_type('balance', 'currency')
|
g.set_type('balance', 'currency')
|
||||||
|
@ -128,6 +140,27 @@ class CustomerView(CoreOfficeMasterView):
|
||||||
customer.card_number,
|
customer.card_number,
|
||||||
office_url=office_url)
|
office_url=office_url)
|
||||||
|
|
||||||
|
def download_results_fields_available(self, **kwargs):
|
||||||
|
fields = super(CustomerView, self).download_results_fields_available(**kwargs)
|
||||||
|
|
||||||
|
fields.extend([
|
||||||
|
'email',
|
||||||
|
'email2',
|
||||||
|
])
|
||||||
|
|
||||||
|
return fields
|
||||||
|
|
||||||
|
def download_results_normalize(self, custdata, fields, **kwargs):
|
||||||
|
data = super(CustomerView, self).download_results_normalize(custdata, fields, **kwargs)
|
||||||
|
|
||||||
|
# import ipdb; ipdb.set_trace()
|
||||||
|
|
||||||
|
for field in ('email', 'email2'):
|
||||||
|
if field in fields:
|
||||||
|
data[field] = getattr(custdata.member_info, field) if custdata.member_info else None
|
||||||
|
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
def includeme(config):
|
def includeme(config):
|
||||||
CustomerView.defaults(config)
|
CustomerView.defaults(config)
|
||||||
|
|
Loading…
Reference in a new issue