Add custom grid filter for phone number fields

and use it in various grid views
This commit is contained in:
Lance Edgar 2019-04-10 14:20:36 -05:00
parent 2bdcc4fe47
commit ec70d85638
6 changed files with 63 additions and 13 deletions

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2018 Lance Edgar
# Copyright © 2010-2019 Lance Edgar
#
# This file is part of Rattail.
#
@ -35,6 +35,7 @@ import colander
from deform import widget as dfwidget
from webhelpers2.html import tags, HTML
from tailbone import grids
from tailbone.db import Session
from tailbone.views import MasterView, AutocompleteView
@ -90,8 +91,9 @@ class EmployeesView(MasterView):
g.filters['email'] = g.make_filter('email', model.EmployeeEmailAddress.address,
label="Email Address")
g.filters['phone'] = g.make_filter('phone', model.EmployeePhoneNumber.number,
label="Phone Number")
g.set_filter('phone', model.EmployeePhoneNumber.number,
label="Phone Number",
factory=grids.filters.AlchemyPhoneNumberFilter)
# id
if self.request.has_perm('{}.edit'.format(route_prefix)):