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:
Lance Edgar 2023-06-12 17:32:02 -05:00
parent 15d4086da2
commit 04c23d4087
2 changed files with 12 additions and 14 deletions

View file

@ -43,12 +43,11 @@ def render_member_info(request, custdata, field):
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_key = ('card_number', 'person_number')
model_class = corepos.CustomerClassic
model_title = "CORE-POS Customer (Legacy)"
model_title_plural = "CORE-POS Customers (Legacy)"
url_prefix = '/core-pos/customers'
@ -80,15 +79,15 @@ class CustomerView(CoreOfficeMasterView):
]
def query(self, session):
query = super(CustomerView, self).query(session)
query = super().query(session)
query = query.outerjoin(corepos.MemberInfo,
corepos.MemberInfo.card_number == corepos.CustData.card_number)
corepos.MemberInfo.card_number == corepos.CustomerClassic.card_number)
return query
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_verb = 'equal'
@ -117,7 +116,7 @@ class CustomerView(CoreOfficeMasterView):
g.set_link('last_name')
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_type', self.render_member_type)
@ -146,7 +145,7 @@ class CustomerView(CoreOfficeMasterView):
office_url=office_url)
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([
'email',
@ -156,7 +155,7 @@ class CustomerView(CoreOfficeMasterView):
return fields
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()
@ -234,8 +233,8 @@ class SuspensionView(CoreOfficeMasterView):
def defaults(config, **kwargs):
base = globals()
CustomerView = kwargs.get('CustomerView', base['CustomerView'])
CustomerView.defaults(config)
CustomerClassicView = kwargs.get('CustomerClassicView', base['CustomerClassicView'])
CustomerClassicView.defaults(config)
SuspensionView = kwargs.get('SuspensionView', base['SuspensionView'])
SuspensionView.defaults(config)

View file

@ -160,8 +160,7 @@ class MemberView(CoreOfficeMasterView):
for customer in customers:
text = str(customer)
url = self.request.route_url('corepos.customers.view',
card_number=customer.card_number,
person_number=customer.person_number)
id=customer.id)
link = tags.link_to(text, url)
items.append(HTML.tag('li', c=[link]))
return HTML.tag('ul', c=items)