Changeset acf6764 in tailbone-corepos


Ignore:
Timestamp:
07/30/2020 11:10:38 AM (3 years ago)
Author:
Lance Edgar <lance@…>
Branches:
master
Children:
69585ad
Parents:
3ae1c9d
Message:

Add better links between CustData? and MemberInfo? tables

Location:
tailbone_corepos/views/corepos
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tailbone_corepos/views/corepos/customers.py

    r3ae1c9d racf6764  
    9797        super(CustomerView, self).configure_form(f)
    9898
    99         # member_type
     99        f.set_renderer('member_info', self.render_member_info)
    100100        f.set_renderer('member_type', self.render_member_type)
    101101
     
    115115        return tags.link_to(text, url)
    116116
     117    def render_member_info(self, custdata, field):
     118        meminfo = custdata.member_info
     119        if not meminfo:
     120            return
     121        text = str(meminfo)
     122        url = self.request.route_url('corepos.members.view',
     123                                     card_number=meminfo.card_number)
     124        return tags.link_to(text, url)
     125
    117126    def core_office_object_url(self, office_url, customer):
    118127        return core_office_customer_account_url(self.rattail_config,
  • tailbone_corepos/views/corepos/members.py

    r3ae1c9d racf6764  
    2727from corepos.db.office_op import model as corepos
    2828
    29 from webhelpers2.html import HTML
     29from webhelpers2.html import HTML, tags
    3030
    3131from .master import CoreOfficeMasterView
     
    112112        f.set_renderer('dates', self.render_member_dates)
    113113
     114        f.append('customers')
     115        f.set_readonly('customers')
     116        f.set_renderer('customers', self.render_customers)
     117
    114118    def render_member_dates(self, member, field):
    115119        if not member.dates:
     
    121125        return HTML.tag('ul', c=items)
    122126
     127    def render_customers(self, member, field):
     128        customers = member.customers
     129        if not customers:
     130            return
     131
     132        items = []
     133        for customer in customers:
     134            text = str(customer)
     135            url = self.request.route_url('corepos.customers.view', id=customer.id)
     136            link = tags.link_to(text, url)
     137            items.append(HTML.tag('li', c=[link]))
     138        return HTML.tag('ul', c=items)
     139
    123140
    124141def includeme(config):
Note: See TracChangeset for help on using the changeset viewer.