diff --git a/rattail/pyramid/templates/products/crud.mako b/rattail/pyramid/templates/products/crud.mako new file mode 100644 index 00000000..1e5ccb97 --- /dev/null +++ b/rattail/pyramid/templates/products/crud.mako @@ -0,0 +1,8 @@ +<%inherit file="/products/base.mako" /> +<%inherit file="/crud.mako" /> + +<%def name="context_menu_items()"> +

${h.link_to("Back to Products", url('products'))}

+ + +${parent.body()} diff --git a/rattail/pyramid/templates/products/read.mako b/rattail/pyramid/templates/products/read.mako new file mode 100644 index 00000000..899e025e --- /dev/null +++ b/rattail/pyramid/templates/products/read.mako @@ -0,0 +1,2 @@ +<%inherit file="/products/crud.mako" /> +${parent.body()} diff --git a/rattail/pyramid/views/products.py b/rattail/pyramid/views/products.py index 77605d49..def4e2ac 100644 --- a/rattail/pyramid/views/products.py +++ b/rattail/pyramid/views/products.py @@ -48,6 +48,7 @@ class ProductsGrid(SearchableAlchemyGridView): route_url = '/products' renderer = '/products/index.mako' sort = 'description' + clickable = True def join_map(self): return { @@ -122,24 +123,34 @@ class ProductsGrid(SearchableAlchemyGridView): ], readonly=True) - def callback(prod): - return link_to("Print", '#', class_='print-label') + def attrs(row, i): + return {'onclick': "location.href = '%s';" + % self.request.route_url('product.read', uuid=row.uuid)} + g.row_attrs = attrs if edbob.config.getboolean('rattail.labels', 'enabled', default=False): - g.add_column('labels', "Labels", callback) + def labels(row): + return link_to("Print", '#', class_='print-label') + g.add_column('labels', "Labels", labels) + return g class ProductCrud(Crud): mapped_class = rattail.Product - home_route = 'products.list' + home_route = 'products' def fieldset(self, obj): fs = self.make_fieldset(obj) fs.configure( include=[ + fs.upc.label("UPC"), + fs.brand, fs.description, + fs.size, + fs.department, + fs.subdepartment, ]) return fs