Tweak GPC grid filter, to better handle spaces in user input
i.e. when a user copy/pastes a UPC with leading/trailing space
This commit is contained in:
parent
136d181363
commit
9a61f55f76
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2019 Lance Edgar
|
# Copyright © 2010-2020 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -859,8 +859,13 @@ class AlchemyGPCFilter(AlchemyGridFilter):
|
||||||
"""
|
"""
|
||||||
Filter data with an equal ('=') query.
|
Filter data with an equal ('=') query.
|
||||||
"""
|
"""
|
||||||
if value is None or value == '':
|
if value is None:
|
||||||
return query
|
return query
|
||||||
|
|
||||||
|
value = value.strip()
|
||||||
|
if not value:
|
||||||
|
return query
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return query.filter(self.column.in_((
|
return query.filter(self.column.in_((
|
||||||
GPC(value),
|
GPC(value),
|
||||||
|
@ -870,9 +875,13 @@ class AlchemyGPCFilter(AlchemyGridFilter):
|
||||||
|
|
||||||
def filter_not_equal(self, query, value):
|
def filter_not_equal(self, query, value):
|
||||||
"""
|
"""
|
||||||
Filter data with a not eqaul ('!=') query.
|
Filter data with a not equal ('!=') query.
|
||||||
"""
|
"""
|
||||||
if value is None or value == '':
|
if value is None:
|
||||||
|
return query
|
||||||
|
|
||||||
|
value = value.strip()
|
||||||
|
if not value:
|
||||||
return query
|
return query
|
||||||
|
|
||||||
# When saying something is 'not equal' to something else, we must also
|
# When saying something is 'not equal' to something else, we must also
|
||||||
|
|
Loading…
Reference in a new issue