add view for CORE Member Contact Preferences
This commit is contained in:
parent
25d1eaa816
commit
1c5e3296d7
|
@ -71,6 +71,11 @@ def make_corepos_menu(request):
|
||||||
'route': 'corepos.member_types',
|
'route': 'corepos.member_types',
|
||||||
'perm': 'corepos.member_types.list',
|
'perm': 'corepos.member_types.list',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'title': "Member Contact Preferences",
|
||||||
|
'route': 'corepos.member_contact_prefs',
|
||||||
|
'perm': 'corepos.member_contact_prefs.list',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
'title': "Employees",
|
'title': "Employees",
|
||||||
'route': 'corepos.employees',
|
'route': 'corepos.employees',
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2023 Lance Edgar
|
# Copyright © 2010-2024 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -26,8 +26,8 @@ CORE-POS member views
|
||||||
|
|
||||||
from sqlalchemy import orm
|
from sqlalchemy import orm
|
||||||
|
|
||||||
from corepos.db.office_op import model as corepos
|
from corepos.db.office_op.model import MemberType, MemberContactPreference, MemberInfo
|
||||||
from corepos.db.office_trans import model as coretrans
|
from corepos.db.office_trans.model import StockPurchase
|
||||||
|
|
||||||
from webhelpers2.html import HTML, tags
|
from webhelpers2.html import HTML, tags
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class MemberTypeView(CoreOfficeMasterView):
|
||||||
"""
|
"""
|
||||||
Master view for member types
|
Master view for member types
|
||||||
"""
|
"""
|
||||||
model_class = corepos.MemberType
|
model_class = MemberType
|
||||||
model_title = "CORE-POS Member Type"
|
model_title = "CORE-POS Member Type"
|
||||||
url_prefix = '/core-pos/member-types'
|
url_prefix = '/core-pos/member-types'
|
||||||
route_prefix = 'corepos.member_types'
|
route_prefix = 'corepos.member_types'
|
||||||
|
@ -56,11 +56,29 @@ class MemberTypeView(CoreOfficeMasterView):
|
||||||
g.set_link('description')
|
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):
|
class MemberView(CoreOfficeMasterView):
|
||||||
"""
|
"""
|
||||||
Master view for members
|
Master view for members
|
||||||
"""
|
"""
|
||||||
model_class = corepos.MemberInfo
|
model_class = MemberInfo
|
||||||
model_title = "CORE-POS Member (classic)"
|
model_title = "CORE-POS Member (classic)"
|
||||||
model_title_plural = "CORE-POS Members (classic)"
|
model_title_plural = "CORE-POS Members (classic)"
|
||||||
url_prefix = '/core-pos/members'
|
url_prefix = '/core-pos/members'
|
||||||
|
@ -107,7 +125,7 @@ class MemberView(CoreOfficeMasterView):
|
||||||
]
|
]
|
||||||
|
|
||||||
has_rows = True
|
has_rows = True
|
||||||
model_row_class = coretrans.StockPurchase
|
model_row_class = StockPurchase
|
||||||
rows_title = "Stock Purchases"
|
rows_title = "Stock Purchases"
|
||||||
|
|
||||||
row_labels = {
|
row_labels = {
|
||||||
|
@ -196,6 +214,9 @@ class MemberView(CoreOfficeMasterView):
|
||||||
return tags.link_to(text, url)
|
return tags.link_to(text, url)
|
||||||
|
|
||||||
def render_equity_live_balance(self, member, field):
|
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:
|
try:
|
||||||
balance = CoreTransSession.query(coretrans.EquityLiveBalance)\
|
balance = CoreTransSession.query(coretrans.EquityLiveBalance)\
|
||||||
.filter(coretrans.EquityLiveBalance.member_number == member.card_number)\
|
.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")]
|
return [self.make_xref_button(url=url, text="View in CORE Office")]
|
||||||
|
|
||||||
def get_row_data(self, member):
|
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)\
|
return CoreTransSession.query(coretrans.StockPurchase)\
|
||||||
.filter(coretrans.StockPurchase.card_number == member.card_number)
|
.filter(coretrans.StockPurchase.card_number == member.card_number)
|
||||||
|
|
||||||
def get_parent(self, stock_purchase):
|
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):
|
def configure_row_grid(self, g):
|
||||||
super().configure_row_grid(g)
|
super().configure_row_grid(g)
|
||||||
|
@ -241,6 +265,9 @@ def defaults(config, **kwargs):
|
||||||
MemberTypeView = kwargs.get('MemberTypeView', base['MemberTypeView'])
|
MemberTypeView = kwargs.get('MemberTypeView', base['MemberTypeView'])
|
||||||
MemberTypeView.defaults(config)
|
MemberTypeView.defaults(config)
|
||||||
|
|
||||||
|
MemberContactPreferenceView = kwargs.get('MemberContactPreferenceView', base['MemberContactPreferenceView'])
|
||||||
|
MemberContactPreferenceView.defaults(config)
|
||||||
|
|
||||||
MemberView = kwargs.get('MemberView', base['MemberView'])
|
MemberView = kwargs.get('MemberView', base['MemberView'])
|
||||||
MemberView.defaults(config)
|
MemberView.defaults(config)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue