Add experimental soundex filter support to the Customers grid.

This commit is contained in:
Lance Edgar 2014-06-12 20:41:25 -07:00
parent 8f1e34c73c
commit 54bb9e2869
3 changed files with 44 additions and 11 deletions

View file

@ -1,9 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2012 Lance Edgar
# Copyright © 2010-2014 Lance Edgar
#
# This file is part of Rattail.
#
@ -58,7 +57,7 @@ class CustomersGrid(SearchableAlchemyGridView):
def filter_map(self):
return self.make_filter_map(
exact=['id'],
ilike=['name'],
name=self.filter_ilike_and_soundex(model.Customer.name),
email=self.filter_ilike(model.CustomerEmailAddress.address),
phone=self.filter_ilike(model.CustomerPhoneNumber.number))

View file

@ -1,9 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2012 Lance Edgar
# Copyright © 2010-2014 Lance Edgar
#
# This file is part of Rattail.
#
@ -139,6 +138,12 @@ class SearchableAlchemyGridView(PagedAlchemyGridView):
def filter_ilike(self, field):
return grids.search.filter_ilike(field)
def filter_soundex(self, field):
return grids.search.filter_soundex(field)
def filter_ilike_and_soundex(self, field):
return grids.search.filter_ilike_and_soundex(field)
def make_filter_map(self, **kwargs):
return grids.search.get_filter_map(self.mapped_class, **kwargs)