add (some of) Product CRUD

This commit is contained in:
Lance Edgar 2012-08-07 17:05:45 -07:00
parent da95cb8614
commit 2cbe1a0c44
3 changed files with 25 additions and 4 deletions

View file

@ -0,0 +1,8 @@
<%inherit file="/products/base.mako" />
<%inherit file="/crud.mako" />
<%def name="context_menu_items()">
<p>${h.link_to("Back to Products", url('products'))}</p>
</%def>
${parent.body()}

View file

@ -0,0 +1,2 @@
<%inherit file="/products/crud.mako" />
${parent.body()}

View file

@ -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