Clean up the basic Member views

This commit is contained in:
Lance Edgar 2019-10-25 16:30:42 -05:00
parent 43facf7691
commit 599a0e5794

View file

@ -24,8 +24,12 @@
CORE-POS member views
"""
import six
from corepos.db import model as corepos
from webhelpers2.html import HTML
from .master import CoreOfficeMasterView
@ -59,6 +63,64 @@ class MemberView(CoreOfficeMasterView):
url_prefix = '/core-pos/members'
route_prefix = 'corepos.members'
labels = {
'card_number': "Card No.",
'email2': "Email 2",
'ads_ok': "Ads OK",
}
grid_columns = [
'card_number',
'first_name',
'last_name',
'street',
'city',
'state',
'zip',
'phone',
'email',
]
form_fields = [
'card_number',
'first_name',
'last_name',
'other_first_name',
'other_last_name',
'street',
'city',
'state',
'zip',
'phone',
'email',
'email2',
'ads_ok',
'dates',
]
def configure_grid(self, g):
super(MemberView, self).configure_grid(g)
g.set_sort_defaults('card_number')
g.set_link('card_number')
g.set_link('first_name')
g.set_link('last_name')
def configure_form(self, f):
super(MemberView, self).configure_form(f)
f.set_renderer('dates', self.render_member_dates)
def render_member_dates(self, member, field):
if not member.dates:
return ""
items = []
for dates in member.dates:
items.append(HTML.tag('li', c=six.text_type(dates)))
return HTML.tag('ul', c=items)
def includeme(config):
MemberTypeView.defaults(config)