From 04c23d40874f0754c1361859cb08abf5491fbb17 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Mon, 12 Jun 2023 17:32:02 -0500 Subject: [PATCH] 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 --- tailbone_corepos/views/corepos/customers.py | 23 ++++++++++----------- tailbone_corepos/views/corepos/members.py | 3 +-- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/tailbone_corepos/views/corepos/customers.py b/tailbone_corepos/views/corepos/customers.py index 42ee7f9..7ca6cbf 100644 --- a/tailbone_corepos/views/corepos/customers.py +++ b/tailbone_corepos/views/corepos/customers.py @@ -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) diff --git a/tailbone_corepos/views/corepos/members.py b/tailbone_corepos/views/corepos/members.py index 3395c5b..8032601 100644 --- a/tailbone_corepos/views/corepos/members.py +++ b/tailbone_corepos/views/corepos/members.py @@ -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)