Rename model for custdata
to CustomerClassic
also its master view should use true ID field instead of card/person numbers, since in some cases those are not unique
This commit is contained in:
parent
15d4086da2
commit
04c23d4087
|
@ -43,12 +43,11 @@ def render_member_info(request, custdata, field):
|
||||||
return tags.link_to(text, url)
|
return tags.link_to(text, url)
|
||||||
|
|
||||||
|
|
||||||
class CustomerView(CoreOfficeMasterView):
|
class CustomerClassicView(CoreOfficeMasterView):
|
||||||
"""
|
"""
|
||||||
Base class for customer views.
|
Master view for "classic" customers, i.e. ``custdata``
|
||||||
"""
|
"""
|
||||||
model_class = corepos.CustData
|
model_class = corepos.CustomerClassic
|
||||||
model_key = ('card_number', 'person_number')
|
|
||||||
model_title = "CORE-POS Customer (Legacy)"
|
model_title = "CORE-POS Customer (Legacy)"
|
||||||
model_title_plural = "CORE-POS Customers (Legacy)"
|
model_title_plural = "CORE-POS Customers (Legacy)"
|
||||||
url_prefix = '/core-pos/customers'
|
url_prefix = '/core-pos/customers'
|
||||||
|
@ -80,15 +79,15 @@ class CustomerView(CoreOfficeMasterView):
|
||||||
]
|
]
|
||||||
|
|
||||||
def query(self, session):
|
def query(self, session):
|
||||||
query = super(CustomerView, self).query(session)
|
query = super().query(session)
|
||||||
|
|
||||||
query = query.outerjoin(corepos.MemberInfo,
|
query = query.outerjoin(corepos.MemberInfo,
|
||||||
corepos.MemberInfo.card_number == corepos.CustData.card_number)
|
corepos.MemberInfo.card_number == corepos.CustomerClassic.card_number)
|
||||||
|
|
||||||
return query
|
return query
|
||||||
|
|
||||||
def configure_grid(self, g):
|
def configure_grid(self, g):
|
||||||
super(CustomerView, self).configure_grid(g)
|
super().configure_grid(g)
|
||||||
|
|
||||||
g.filters['card_number'].default_active = True
|
g.filters['card_number'].default_active = True
|
||||||
g.filters['card_number'].default_verb = 'equal'
|
g.filters['card_number'].default_verb = 'equal'
|
||||||
|
@ -117,7 +116,7 @@ class CustomerView(CoreOfficeMasterView):
|
||||||
g.set_link('last_name')
|
g.set_link('last_name')
|
||||||
|
|
||||||
def configure_form(self, f):
|
def configure_form(self, f):
|
||||||
super(CustomerView, self).configure_form(f)
|
super().configure_form(f)
|
||||||
|
|
||||||
f.set_renderer('member_info', self.render_member_info)
|
f.set_renderer('member_info', self.render_member_info)
|
||||||
f.set_renderer('member_type', self.render_member_type)
|
f.set_renderer('member_type', self.render_member_type)
|
||||||
|
@ -146,7 +145,7 @@ class CustomerView(CoreOfficeMasterView):
|
||||||
office_url=office_url)
|
office_url=office_url)
|
||||||
|
|
||||||
def download_results_fields_available(self, **kwargs):
|
def download_results_fields_available(self, **kwargs):
|
||||||
fields = super(CustomerView, self).download_results_fields_available(**kwargs)
|
fields = super().download_results_fields_available(**kwargs)
|
||||||
|
|
||||||
fields.extend([
|
fields.extend([
|
||||||
'email',
|
'email',
|
||||||
|
@ -156,7 +155,7 @@ class CustomerView(CoreOfficeMasterView):
|
||||||
return fields
|
return fields
|
||||||
|
|
||||||
def download_results_normalize(self, custdata, fields, **kwargs):
|
def download_results_normalize(self, custdata, fields, **kwargs):
|
||||||
data = super(CustomerView, self).download_results_normalize(custdata, fields, **kwargs)
|
data = super().download_results_normalize(custdata, fields, **kwargs)
|
||||||
|
|
||||||
# import ipdb; ipdb.set_trace()
|
# import ipdb; ipdb.set_trace()
|
||||||
|
|
||||||
|
@ -234,8 +233,8 @@ class SuspensionView(CoreOfficeMasterView):
|
||||||
def defaults(config, **kwargs):
|
def defaults(config, **kwargs):
|
||||||
base = globals()
|
base = globals()
|
||||||
|
|
||||||
CustomerView = kwargs.get('CustomerView', base['CustomerView'])
|
CustomerClassicView = kwargs.get('CustomerClassicView', base['CustomerClassicView'])
|
||||||
CustomerView.defaults(config)
|
CustomerClassicView.defaults(config)
|
||||||
|
|
||||||
SuspensionView = kwargs.get('SuspensionView', base['SuspensionView'])
|
SuspensionView = kwargs.get('SuspensionView', base['SuspensionView'])
|
||||||
SuspensionView.defaults(config)
|
SuspensionView.defaults(config)
|
||||||
|
|
|
@ -160,8 +160,7 @@ class MemberView(CoreOfficeMasterView):
|
||||||
for customer in customers:
|
for customer in customers:
|
||||||
text = str(customer)
|
text = str(customer)
|
||||||
url = self.request.route_url('corepos.customers.view',
|
url = self.request.route_url('corepos.customers.view',
|
||||||
card_number=customer.card_number,
|
id=customer.id)
|
||||||
person_number=customer.person_number)
|
|
||||||
link = tags.link_to(text, url)
|
link = tags.link_to(text, url)
|
||||||
items.append(HTML.tag('li', c=[link]))
|
items.append(HTML.tag('li', c=[link]))
|
||||||
return HTML.tag('ul', c=items)
|
return HTML.tag('ul', c=items)
|
||||||
|
|
Loading…
Reference in a new issue