add view for CORE Member Contact Preferences

This commit is contained in:
Lance Edgar 2024-08-06 11:33:01 -05:00
parent 25d1eaa816
commit 1c5e3296d7
2 changed files with 39 additions and 7 deletions

View file

@ -71,6 +71,11 @@ def make_corepos_menu(request):
'route': 'corepos.member_types',
'perm': 'corepos.member_types.list',
},
{
'title': "Member Contact Preferences",
'route': 'corepos.member_contact_prefs',
'perm': 'corepos.member_contact_prefs.list',
},
{
'title': "Employees",
'route': 'corepos.employees',

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2023 Lance Edgar
# Copyright © 2010-2024 Lance Edgar
#
# This file is part of Rattail.
#
@ -26,8 +26,8 @@ CORE-POS member views
from sqlalchemy import orm
from corepos.db.office_op import model as corepos
from corepos.db.office_trans import model as coretrans
from corepos.db.office_op.model import MemberType, MemberContactPreference, MemberInfo
from corepos.db.office_trans.model import StockPurchase
from webhelpers2.html import HTML, tags
@ -39,7 +39,7 @@ class MemberTypeView(CoreOfficeMasterView):
"""
Master view for member types
"""
model_class = corepos.MemberType
model_class = MemberType
model_title = "CORE-POS Member Type"
url_prefix = '/core-pos/member-types'
route_prefix = 'corepos.member_types'
@ -56,11 +56,29 @@ class MemberTypeView(CoreOfficeMasterView):
g.set_link('description')
class MemberContactPreferenceView(CoreOfficeMasterView):
"""
Master view for member contact preferences
"""
model_class = MemberContactPreference
model_title = "CORE-POS Member Contact Preference"
url_prefix = '/core-pos/member-contact-prefs'
route_prefix = 'corepos.member_contact_prefs'
def configure_grid(self, g):
super().configure_grid(g)
g.set_sort_defaults('id')
g.set_link('id')
g.set_link('description')
class MemberView(CoreOfficeMasterView):
"""
Master view for members
"""
model_class = corepos.MemberInfo
model_class = MemberInfo
model_title = "CORE-POS Member (classic)"
model_title_plural = "CORE-POS Members (classic)"
url_prefix = '/core-pos/members'
@ -107,7 +125,7 @@ class MemberView(CoreOfficeMasterView):
]
has_rows = True
model_row_class = coretrans.StockPurchase
model_row_class = StockPurchase
rows_title = "Stock Purchases"
row_labels = {
@ -196,6 +214,9 @@ class MemberView(CoreOfficeMasterView):
return tags.link_to(text, url)
def render_equity_live_balance(self, member, field):
app = self.get_rattail_app()
corepos = app.get_corepos_handler()
coretrans = corepos.get_model_office_trans()
try:
balance = CoreTransSession.query(coretrans.EquityLiveBalance)\
.filter(coretrans.EquityLiveBalance.member_number == member.card_number)\
@ -214,11 +235,14 @@ class MemberView(CoreOfficeMasterView):
return [self.make_xref_button(url=url, text="View in CORE Office")]
def get_row_data(self, member):
app = self.get_rattail_app()
corepos = app.get_corepos_handler()
coretrans = corepos.get_model_office_trans()
return CoreTransSession.query(coretrans.StockPurchase)\
.filter(coretrans.StockPurchase.card_number == member.card_number)
def get_parent(self, stock_purchase):
return self.Session.get(corepos.MemberInfo, stock_purchase.card_number)
return self.Session.get(MemberInfo, stock_purchase.card_number)
def configure_row_grid(self, g):
super().configure_row_grid(g)
@ -241,6 +265,9 @@ def defaults(config, **kwargs):
MemberTypeView = kwargs.get('MemberTypeView', base['MemberTypeView'])
MemberTypeView.defaults(config)
MemberContactPreferenceView = kwargs.get('MemberContactPreferenceView', base['MemberContactPreferenceView'])
MemberContactPreferenceView.defaults(config)
MemberView = kwargs.get('MemberView', base['MemberView'])
MemberView.defaults(config)