From 047c35ab75e5ba3d636f35f199e53a21e88fc5ab Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 10 Sep 2013 06:35:17 -0700 Subject: [PATCH] Changed vendor filter in product search to find "any vendor". I.e. the current filter is ''not'' restricted to the preferred vendor only. Probably should still add one (back) for preferred only as well; hence the commented code. --- tailbone/views/products.py | 40 ++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/tailbone/views/products.py b/tailbone/views/products.py index 8f14d7c2..d4ac3b30 100644 --- a/tailbone/views/products.py +++ b/tailbone/views/products.py @@ -61,15 +61,21 @@ class ProductsGrid(SearchableAlchemyGridView): def join_map(self): - def join_vendor(q): - q = q.outerjoin( - ProductCost, - and_( - ProductCost.product_uuid == Product.uuid, - ProductCost.preference == 1, - )) - q = q.outerjoin(Vendor) - return q + # def join_vendor(q): + # q = q.outerjoin( + # ProductCost, + # ProductCost.product_uuid == Product.uuid, + # and_( + # ProductCost.product_uuid == Product.uuid, + # ProductCost.preference == 1, + # )) + # q = q.outerjoin(Vendor) + # return q + + def join_vendor_any(q): + return q.outerjoin(ProductCost, + ProductCost.product_uuid == Product.uuid)\ + .outerjoin(Vendor) return { 'brand': @@ -86,8 +92,10 @@ class ProductsGrid(SearchableAlchemyGridView): 'current_price': lambda q: q.outerjoin(ProductPrice, ProductPrice.uuid == Product.current_price_uuid), - 'vendor': - join_vendor, + # 'vendor': + # join_vendor, + 'vendor_any': + join_vendor_any, 'code': lambda q: q.outerjoin(ProductCode), } @@ -122,7 +130,8 @@ class ProductsGrid(SearchableAlchemyGridView): brand=self.filter_ilike(Brand.name), department=self.filter_ilike(Department.name), subdepartment=self.filter_ilike(Subdepartment.name), - vendor=self.filter_ilike(Vendor.name), + # vendor=self.filter_ilike(Vendor.name), + vendor_any=self.filter_ilike(Vendor.name), code=self.filter_ilike(ProductCode.code)) def filter_config(self): @@ -136,8 +145,9 @@ class ProductsGrid(SearchableAlchemyGridView): filter_type_description='lk', include_filter_department=True, filter_type_department='lk', - include_filter_vendor=True, - filter_type_vendor='lk') + include_filter_vendor_any=True, + filter_label_vendor_any="Vendor (any)", + filter_type_vendor_any='lk') def sort_map(self): return self.make_sort_map( @@ -171,7 +181,7 @@ class ProductsGrid(SearchableAlchemyGridView): g.description, g.size, g.subdepartment, - g.vendor, + g.vendor.label("Pref. Vendor"), g.regular_price.label("Reg. Price"), g.current_price.label("Cur. Price"), ],