Changeset 92f6226 in tailbone-corepos


Ignore:
Timestamp:
07/15/2020 10:15:43 PM (3 years ago)
Author:
Lance Edgar <lance@…>
Branches:
master
Children:
c18be17
Parents:
b5036eb
Message:

Include member type column for legacy customers grid

File:
1 edited

Legend:

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

    rb5036eb r92f6226  
    2929from rattail_corepos.config import core_office_customer_account_url
    3030
     31from webhelpers2.html import tags
     32
    3133from .master import CoreOfficeMasterView
    3234
     
    5557        'first_name',
    5658        'last_name',
     59        'member_type',
    5760        'charge_ok',
    5861        'charge_limit',
     
    7174        g.filters['last_name'].default_verb = 'contains'
    7275
     76        g.set_joiner('member_type', lambda q: q.outerjoin(corepos.MemberType))
     77        g.set_sorter('member_type', corepos.MemberType.description)
     78        g.set_filter('member_type', corepos.MemberType.description)
     79
    7380        g.set_type('charge_limit', 'currency')
    7481        g.set_type('balance', 'currency')
     
    8491        super(CustomerView, self).configure_form(f)
    8592
     93        # member_type
     94        f.set_renderer('member_type', self.render_member_type)
     95
    8696        if self.creating or self.editing:
    8797            f.remove_field('member_info')
     
    90100        else:
    91101            f.set_type('last_change', 'datetime_local')
     102
     103    def render_member_type(self, custdata, field):
     104        memtype = custdata.member_type
     105        if not memtype:
     106            return
     107        text = str(memtype)
     108        url = self.request.route_url('corepos.member_types.view', id=memtype.id)
     109        return tags.link_to(text, url)
    92110
    93111    def core_office_object_url(self, office_url, customer):
Note: See TracChangeset for help on using the changeset viewer.