add type check to product upc search filter
This commit is contained in:
parent
ae40b15977
commit
5f7fd2401e
|
@ -88,9 +88,30 @@ class ProductsGrid(SearchableAlchemyGridView):
|
||||||
}
|
}
|
||||||
|
|
||||||
def filter_map(self):
|
def filter_map(self):
|
||||||
|
|
||||||
|
def filter_upc():
|
||||||
|
|
||||||
|
def filter_is(q, v):
|
||||||
|
try:
|
||||||
|
v = int(v)
|
||||||
|
except ValueError:
|
||||||
|
return q
|
||||||
|
else:
|
||||||
|
return q.filter(field == v) if v else q
|
||||||
|
|
||||||
|
def filter_not(q, v):
|
||||||
|
try:
|
||||||
|
v = int(v)
|
||||||
|
except ValueError:
|
||||||
|
return q
|
||||||
|
else:
|
||||||
|
return q.filter(field != v) if v else q
|
||||||
|
|
||||||
|
return {'is': filter_is, 'nt': filter_not}
|
||||||
|
|
||||||
return self.make_filter_map(
|
return self.make_filter_map(
|
||||||
exact=['upc'],
|
|
||||||
ilike=['description', 'size'],
|
ilike=['description', 'size'],
|
||||||
|
upc=filter_upc(),
|
||||||
brand=self.filter_ilike(rattail.Brand.name),
|
brand=self.filter_ilike(rattail.Brand.name),
|
||||||
department=self.filter_ilike(rattail.Department.name),
|
department=self.filter_ilike(rattail.Department.name),
|
||||||
subdepartment=self.filter_ilike(rattail.Subdepartment.name),
|
subdepartment=self.filter_ilike(rattail.Subdepartment.name),
|
||||||
|
|
Loading…
Reference in a new issue