Add views for CORE new-style Customer, CustomerAccount

and rename "Legacy" to "classic" for old-style table views, menus
This commit is contained in:
Lance Edgar 2023-06-12 20:05:39 -05:00
parent 04c23d4087
commit 35d200eb8e
3 changed files with 88 additions and 7 deletions

View file

@ -38,15 +38,25 @@ def make_corepos_menu(request):
'type': 'menu', 'type': 'menu',
'items': [ 'items': [
{ {
'title': "Customers (Legacy)", 'title': "Customers (classic)",
'route': 'corepos.customers', 'route': 'corepos.customers',
'perm': 'corepos.customers.list', 'perm': 'corepos.customers.list',
}, },
{ {
'title': "Members (Legacy)", 'title': "Members (classic)",
'route': 'corepos.members', 'route': 'corepos.members',
'perm': 'corepos.members.list', '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", 'title': "Suspensions",
'route': 'corepos.suspensions', 'route': 'corepos.suspensions',

View file

@ -45,11 +45,11 @@ def render_member_info(request, custdata, field):
class CustomerClassicView(CoreOfficeMasterView): 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_class = corepos.CustomerClassic
model_title = "CORE-POS Customer (Legacy)" model_title = "CORE-POS Customer (classic)"
model_title_plural = "CORE-POS Customers (Legacy)" model_title_plural = "CORE-POS Customers (classic)"
url_prefix = '/core-pos/customers' url_prefix = '/core-pos/customers'
route_prefix = 'corepos.customers' route_prefix = 'corepos.customers'
results_downloadable = True results_downloadable = True
@ -166,6 +166,71 @@ class CustomerClassicView(CoreOfficeMasterView):
return data 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): class SuspensionView(CoreOfficeMasterView):
""" """
Master view for legacy customer suspensions. Master view for legacy customer suspensions.
@ -236,6 +301,12 @@ def defaults(config, **kwargs):
CustomerClassicView = kwargs.get('CustomerClassicView', base['CustomerClassicView']) CustomerClassicView = kwargs.get('CustomerClassicView', base['CustomerClassicView'])
CustomerClassicView.defaults(config) 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 = kwargs.get('SuspensionView', base['SuspensionView'])
SuspensionView.defaults(config) SuspensionView.defaults(config)

View file

@ -59,8 +59,8 @@ class MemberView(CoreOfficeMasterView):
Master view for members Master view for members
""" """
model_class = corepos.MemberInfo model_class = corepos.MemberInfo
model_title = "CORE-POS Member (Legacy)" model_title = "CORE-POS Member (classic)"
model_title_plural = "CORE-POS Members (Legacy)" model_title_plural = "CORE-POS Members (classic)"
url_prefix = '/core-pos/members' url_prefix = '/core-pos/members'
route_prefix = 'corepos.members' route_prefix = 'corepos.members'