Add better links between CustData and MemberInfo tables
This commit is contained in:
parent
3ae1c9de1f
commit
acf6764cbb
|
@ -96,7 +96,7 @@ class CustomerView(CoreOfficeMasterView):
|
||||||
def configure_form(self, f):
|
def configure_form(self, f):
|
||||||
super(CustomerView, self).configure_form(f)
|
super(CustomerView, self).configure_form(f)
|
||||||
|
|
||||||
# member_type
|
f.set_renderer('member_info', self.render_member_info)
|
||||||
f.set_renderer('member_type', self.render_member_type)
|
f.set_renderer('member_type', self.render_member_type)
|
||||||
|
|
||||||
if self.creating or self.editing:
|
if self.creating or self.editing:
|
||||||
|
@ -114,6 +114,15 @@ class CustomerView(CoreOfficeMasterView):
|
||||||
url = self.request.route_url('corepos.member_types.view', id=memtype.id)
|
url = self.request.route_url('corepos.member_types.view', id=memtype.id)
|
||||||
return tags.link_to(text, url)
|
return tags.link_to(text, url)
|
||||||
|
|
||||||
|
def render_member_info(self, custdata, field):
|
||||||
|
meminfo = custdata.member_info
|
||||||
|
if not meminfo:
|
||||||
|
return
|
||||||
|
text = str(meminfo)
|
||||||
|
url = self.request.route_url('corepos.members.view',
|
||||||
|
card_number=meminfo.card_number)
|
||||||
|
return tags.link_to(text, url)
|
||||||
|
|
||||||
def core_office_object_url(self, office_url, customer):
|
def core_office_object_url(self, office_url, customer):
|
||||||
return core_office_customer_account_url(self.rattail_config,
|
return core_office_customer_account_url(self.rattail_config,
|
||||||
customer.card_number,
|
customer.card_number,
|
||||||
|
|
|
@ -26,7 +26,7 @@ CORE-POS member views
|
||||||
|
|
||||||
from corepos.db.office_op import model as corepos
|
from corepos.db.office_op import model as corepos
|
||||||
|
|
||||||
from webhelpers2.html import HTML
|
from webhelpers2.html import HTML, tags
|
||||||
|
|
||||||
from .master import CoreOfficeMasterView
|
from .master import CoreOfficeMasterView
|
||||||
|
|
||||||
|
@ -111,6 +111,10 @@ class MemberView(CoreOfficeMasterView):
|
||||||
|
|
||||||
f.set_renderer('dates', self.render_member_dates)
|
f.set_renderer('dates', self.render_member_dates)
|
||||||
|
|
||||||
|
f.append('customers')
|
||||||
|
f.set_readonly('customers')
|
||||||
|
f.set_renderer('customers', self.render_customers)
|
||||||
|
|
||||||
def render_member_dates(self, member, field):
|
def render_member_dates(self, member, field):
|
||||||
if not member.dates:
|
if not member.dates:
|
||||||
return ""
|
return ""
|
||||||
|
@ -120,6 +124,19 @@ class MemberView(CoreOfficeMasterView):
|
||||||
items.append(HTML.tag('li', c=str(dates)))
|
items.append(HTML.tag('li', c=str(dates)))
|
||||||
return HTML.tag('ul', c=items)
|
return HTML.tag('ul', c=items)
|
||||||
|
|
||||||
|
def render_customers(self, member, field):
|
||||||
|
customers = member.customers
|
||||||
|
if not customers:
|
||||||
|
return
|
||||||
|
|
||||||
|
items = []
|
||||||
|
for customer in customers:
|
||||||
|
text = str(customer)
|
||||||
|
url = self.request.route_url('corepos.customers.view', id=customer.id)
|
||||||
|
link = tags.link_to(text, url)
|
||||||
|
items.append(HTML.tag('li', c=[link]))
|
||||||
|
return HTML.tag('ul', c=items)
|
||||||
|
|
||||||
|
|
||||||
def includeme(config):
|
def includeme(config):
|
||||||
MemberTypeView.defaults(config)
|
MemberTypeView.defaults(config)
|
||||||
|
|
Loading…
Reference in a new issue