Tweak how a grid filter factory is determined

Don't inspect anything if a factory is provided by caller.
This commit is contained in:
Lance Edgar 2016-09-19 16:34:12 -05:00
parent 65d1c24230
commit 1c45472fe5

View file

@ -93,22 +93,23 @@ class AlchemyGrid(Grid):
"""
Make a filter suitable for use with the given column.
"""
factory = filters.AlchemyGridFilter
if isinstance(column.type, sa.String):
factory = filters.AlchemyStringFilter
elif isinstance(column.type, sa.Numeric):
factory = filters.AlchemyNumericFilter
elif isinstance(column.type, sa.Integer):
factory = filters.AlchemyNumericFilter
elif isinstance(column.type, sa.Boolean):
factory = filters.AlchemyBooleanFilter
elif isinstance(column.type, sa.Date):
factory = filters.AlchemyDateFilter
elif isinstance(column.type, sa.DateTime):
factory = filters.AlchemyDateTimeFilter
elif isinstance(column.type, GPCType):
factory = filters.AlchemyGPCFilter
factory = kwargs.pop('factory', factory)
factory = kwargs.pop('factory', None)
if not factory:
factory = filters.AlchemyGridFilter
if isinstance(column.type, sa.String):
factory = filters.AlchemyStringFilter
elif isinstance(column.type, sa.Numeric):
factory = filters.AlchemyNumericFilter
elif isinstance(column.type, sa.Integer):
factory = filters.AlchemyNumericFilter
elif isinstance(column.type, sa.Boolean):
factory = filters.AlchemyBooleanFilter
elif isinstance(column.type, sa.Date):
factory = filters.AlchemyDateFilter
elif isinstance(column.type, sa.DateTime):
factory = filters.AlchemyDateTimeFilter
elif isinstance(column.type, GPCType):
factory = filters.AlchemyGPCFilter
return factory(key, column=column, config=self.request.rattail_config, **kwargs)
def iter_filters(self):