add (some of) Product CRUD
This commit is contained in:
parent
da95cb8614
commit
2cbe1a0c44
8
rattail/pyramid/templates/products/crud.mako
Normal file
8
rattail/pyramid/templates/products/crud.mako
Normal 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()}
|
2
rattail/pyramid/templates/products/read.mako
Normal file
2
rattail/pyramid/templates/products/read.mako
Normal file
|
@ -0,0 +1,2 @@
|
|||
<%inherit file="/products/crud.mako" />
|
||||
${parent.body()}
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue