Add integer-specific grid filter
this was necessary for smarter handling of "invalid" input, e.g. '.645' is not a good value when querying integer fields
This commit is contained in:
parent
cac9de3cc7
commit
3688979b8f
|
@ -416,7 +416,7 @@ class Grid(object):
|
||||||
elif isinstance(column.type, sa.Numeric):
|
elif isinstance(column.type, sa.Numeric):
|
||||||
factory = gridfilters.AlchemyNumericFilter
|
factory = gridfilters.AlchemyNumericFilter
|
||||||
elif isinstance(column.type, sa.Integer):
|
elif isinstance(column.type, sa.Integer):
|
||||||
factory = gridfilters.AlchemyNumericFilter
|
factory = gridfilters.AlchemyIntegerFilter
|
||||||
elif isinstance(column.type, sa.Boolean):
|
elif isinstance(column.type, sa.Boolean):
|
||||||
# TODO: check column for nullable here?
|
# TODO: check column for nullable here?
|
||||||
factory = gridfilters.AlchemyNullableBooleanFilter
|
factory = gridfilters.AlchemyNullableBooleanFilter
|
||||||
|
|
|
@ -460,6 +460,18 @@ class AlchemyNumericFilter(AlchemyGridFilter):
|
||||||
return super(AlchemyNumericFilter, self).filter_less_equal(query, value)
|
return super(AlchemyNumericFilter, self).filter_less_equal(query, value)
|
||||||
|
|
||||||
|
|
||||||
|
class AlchemyIntegerFilter(AlchemyNumericFilter):
|
||||||
|
"""
|
||||||
|
Integer filter for SQLAlchemy.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def value_invalid(self, value):
|
||||||
|
if value:
|
||||||
|
if not value.isdigit():
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class AlchemyBooleanFilter(AlchemyGridFilter):
|
class AlchemyBooleanFilter(AlchemyGridFilter):
|
||||||
"""
|
"""
|
||||||
Boolean filter for SQLAlchemy.
|
Boolean filter for SQLAlchemy.
|
||||||
|
|
Loading…
Reference in a new issue