Make product UPC search view strip non-digit chars from input.
This is to accomodate the apparently frequent use case of copy/paste which includes the check digit as a "-X" type suffix.
This commit is contained in:
parent
d5a8d19165
commit
2a04caaf99
|
@ -20,7 +20,6 @@
|
|||
# along with Rattail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
"""
|
||||
Product Views
|
||||
"""
|
||||
|
@ -28,6 +27,7 @@ Product Views
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
from sqlalchemy import and_
|
||||
from sqlalchemy.orm import joinedload, aliased
|
||||
|
@ -295,9 +295,9 @@ def products_search(request):
|
|||
Eventually this should be more generic, or at least offer more fields for
|
||||
search. For now it operates only on the ``Product.upc`` field.
|
||||
"""
|
||||
|
||||
product = None
|
||||
upc = request.GET.get('upc')
|
||||
upc = request.GET.get('upc', '').strip()
|
||||
upc = re.sub(r'\D', '', upc)
|
||||
if upc:
|
||||
product = get_product_by_upc(Session, upc)
|
||||
if not product:
|
||||
|
|
Loading…
Reference in a new issue