add subdepartment to products grid
This commit is contained in:
parent
9a8c647b25
commit
910e6ed970
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
from webhelpers.html.tags import link_to
|
from webhelpers.html.tags import link_to
|
||||||
|
|
||||||
|
from sqlalchemy.orm import joinedload
|
||||||
|
|
||||||
from edbob.pyramid.filters import filter_ilike
|
from edbob.pyramid.filters import filter_ilike
|
||||||
from edbob.pyramid.grids import sorter
|
from edbob.pyramid.grids import sorter
|
||||||
from edbob.pyramid.views import GridView
|
from edbob.pyramid.views import GridView
|
||||||
|
@ -53,7 +55,11 @@ class ProductGrid(GridView):
|
||||||
'brand':
|
'brand':
|
||||||
lambda q: q.outerjoin(rattail.Brand),
|
lambda q: q.outerjoin(rattail.Brand),
|
||||||
'department':
|
'department':
|
||||||
lambda q: q.outerjoin(rattail.Department),
|
lambda q: q.outerjoin(rattail.Department,
|
||||||
|
rattail.Product.department_uuid == rattail.Department.uuid),
|
||||||
|
'subdepartment':
|
||||||
|
lambda q: q.outerjoin(rattail.Subdepartment,
|
||||||
|
rattail.Product.subdepartment_uuid == rattail.Subdepartment.uuid),
|
||||||
}
|
}
|
||||||
|
|
||||||
def filter_map(self):
|
def filter_map(self):
|
||||||
|
@ -61,7 +67,8 @@ class ProductGrid(GridView):
|
||||||
exact=['upc'],
|
exact=['upc'],
|
||||||
ilike=['description', 'size'],
|
ilike=['description', 'size'],
|
||||||
brand=filter_ilike(rattail.Brand.name),
|
brand=filter_ilike(rattail.Brand.name),
|
||||||
department=filter_ilike(rattail.Department.name))
|
department=filter_ilike(rattail.Department.name),
|
||||||
|
subdepartment=filter_ilike(rattail.Subdepartment.name))
|
||||||
|
|
||||||
def search_config(self, fmap):
|
def search_config(self, fmap):
|
||||||
return self.make_search_config(
|
return self.make_search_config(
|
||||||
|
@ -90,7 +97,15 @@ class ProductGrid(GridView):
|
||||||
return self.make_sort_map(
|
return self.make_sort_map(
|
||||||
'upc', 'description', 'size', 'regular_price', 'sale_price',
|
'upc', 'description', 'size', 'regular_price', 'sale_price',
|
||||||
brand=sorter(rattail.Brand.name),
|
brand=sorter(rattail.Brand.name),
|
||||||
department=sorter(rattail.Department.name))
|
department=sorter(rattail.Department.name),
|
||||||
|
subdepartment=sorter(rattail.Subdepartment.name))
|
||||||
|
|
||||||
|
def query(self, config):
|
||||||
|
q = self.make_query(config)
|
||||||
|
q = q.options(joinedload(rattail.Product.department))
|
||||||
|
q = q.options(joinedload(rattail.Product.subdepartment))
|
||||||
|
q = q.options(joinedload(rattail.Product.brand))
|
||||||
|
return q
|
||||||
|
|
||||||
def grid(self, data, config):
|
def grid(self, data, config):
|
||||||
g = self.make_grid(data, config)
|
g = self.make_grid(data, config)
|
||||||
|
@ -103,7 +118,8 @@ class ProductGrid(GridView):
|
||||||
g.brand,
|
g.brand,
|
||||||
g.description,
|
g.description,
|
||||||
g.size,
|
g.size,
|
||||||
g.department,
|
# g.department,
|
||||||
|
g.subdepartment,
|
||||||
g.regular_price.label("Reg Price"),
|
g.regular_price.label("Reg Price"),
|
||||||
g.sale_price.label("Sale Price"),
|
g.sale_price.label("Sale Price"),
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue