From 35d200eb8e02e85a491ba21710c393e5af334309 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Mon, 12 Jun 2023 20:05:39 -0500 Subject: [PATCH] Add views for CORE new-style Customer, CustomerAccount and rename "Legacy" to "classic" for old-style table views, menus --- tailbone_corepos/menus.py | 14 +++- tailbone_corepos/views/corepos/customers.py | 77 ++++++++++++++++++++- tailbone_corepos/views/corepos/members.py | 4 +- 3 files changed, 88 insertions(+), 7 deletions(-) diff --git a/tailbone_corepos/menus.py b/tailbone_corepos/menus.py index 53a277c..b55931e 100644 --- a/tailbone_corepos/menus.py +++ b/tailbone_corepos/menus.py @@ -38,15 +38,25 @@ def make_corepos_menu(request): 'type': 'menu', 'items': [ { - 'title': "Customers (Legacy)", + 'title': "Customers (classic)", 'route': 'corepos.customers', 'perm': 'corepos.customers.list', }, { - 'title': "Members (Legacy)", + 'title': "Members (classic)", 'route': 'corepos.members', 'perm': 'corepos.members.list', }, + { + 'title': "Customers (new)", + 'route': 'corepos.customers_new', + 'perm': 'corepos.customers_new.list', + }, + { + 'title': "Customer Accounts (new)", + 'route': 'corepos.customer_accounts_new', + 'perm': 'corepos.customer_accounts_new.list', + }, { 'title': "Suspensions", 'route': 'corepos.suspensions', diff --git a/tailbone_corepos/views/corepos/customers.py b/tailbone_corepos/views/corepos/customers.py index 7ca6cbf..fd1ff65 100644 --- a/tailbone_corepos/views/corepos/customers.py +++ b/tailbone_corepos/views/corepos/customers.py @@ -45,11 +45,11 @@ def render_member_info(request, custdata, field): class CustomerClassicView(CoreOfficeMasterView): """ - Master view for "classic" customers, i.e. ``custdata`` + Master view for "classic" customers, i.e. ``custdata`` table """ model_class = corepos.CustomerClassic - model_title = "CORE-POS Customer (Legacy)" - model_title_plural = "CORE-POS Customers (Legacy)" + model_title = "CORE-POS Customer (classic)" + model_title_plural = "CORE-POS Customers (classic)" url_prefix = '/core-pos/customers' route_prefix = 'corepos.customers' results_downloadable = True @@ -166,6 +166,71 @@ class CustomerClassicView(CoreOfficeMasterView): return data +class CustomerAccountView(CoreOfficeMasterView): + """ + Master view for "new" customer accounts, i.e. ``CustomerAccounts`` + table + """ + model_class = corepos.CustomerAccount + model_title = "CORE-POS Customer Account (new)" + model_title_plural = "CORE-POS Customer Accounts (new)" + url_prefix = '/core-pos/customer-accounts-new' + route_prefix = 'corepos.customer_accounts_new' + results_downloadable = True + + grid_columns = [ + 'id', + 'card_number', + 'member_status', + 'active_status', + 'customer_type', + 'start_date', + 'end_date', + 'modified', + ] + + def configure_grid(self, g): + super().configure_grid(g) + + g.filters['card_number'].default_active = True + g.filters['card_number'].default_verb = 'equal' + g.set_sort_defaults('card_number') + + +class CustomerView(CoreOfficeMasterView): + """ + Master view for "new" customers, i.e. ``Customers`` table + """ + model_class = corepos.Customer + model_title = "CORE-POS Customer (new)" + model_title_plural = "CORE-POS Customers (new)" + url_prefix = '/core-pos/customers-new' + route_prefix = 'corepos.customers_new' + results_downloadable = True + + labels = { + 'account_id': "Account ID", + } + + grid_columns = [ + 'id', + 'account', + 'card_number', + 'first_name', + 'last_name', + 'account_holder', + 'staff', + 'modified', + ] + + def configure_grid(self, g): + super().configure_grid(g) + + g.filters['card_number'].default_active = True + g.filters['card_number'].default_verb = 'equal' + g.set_sort_defaults('card_number') + + class SuspensionView(CoreOfficeMasterView): """ Master view for legacy customer suspensions. @@ -236,6 +301,12 @@ def defaults(config, **kwargs): CustomerClassicView = kwargs.get('CustomerClassicView', base['CustomerClassicView']) CustomerClassicView.defaults(config) + CustomerAccountView = kwargs.get('CustomerAccountView', base['CustomerAccountView']) + CustomerAccountView.defaults(config) + + CustomerView = kwargs.get('CustomerView', base['CustomerView']) + CustomerView.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 8032601..9abe263 100644 --- a/tailbone_corepos/views/corepos/members.py +++ b/tailbone_corepos/views/corepos/members.py @@ -59,8 +59,8 @@ class MemberView(CoreOfficeMasterView): Master view for members """ model_class = corepos.MemberInfo - model_title = "CORE-POS Member (Legacy)" - model_title_plural = "CORE-POS Members (Legacy)" + model_title = "CORE-POS Member (classic)" + model_title_plural = "CORE-POS Members (classic)" url_prefix = '/core-pos/members' route_prefix = 'corepos.members'