Add hyperlinks to product UPC and description, within main grid
These won't honor the indexing scheme yet, still need to think about that.
This commit is contained in:
parent
b718336ac2
commit
aaa1d17507
2 changed files with 35 additions and 8 deletions
|
@ -70,6 +70,21 @@ from tailbone.progress import SessionProgress
|
|||
# return query
|
||||
|
||||
|
||||
class DescriptionFieldRenderer(fa.TextFieldRenderer):
|
||||
"""
|
||||
Renderer for product descriptions within the grid; adds hyperlink.
|
||||
"""
|
||||
|
||||
def render_readonly(self, **kwargs):
|
||||
description = self.raw_value
|
||||
if description is None:
|
||||
return ''
|
||||
if kwargs.get('link'):
|
||||
product = self.field.parent.model
|
||||
description = tags.link_to(description, kwargs['link'](product))
|
||||
return description
|
||||
|
||||
|
||||
class ProductsView(MasterView):
|
||||
"""
|
||||
Master view for the Product class.
|
||||
|
@ -166,9 +181,16 @@ class ProductsView(MasterView):
|
|||
g.filters['vendor_any'] = g.make_filter('vendor_any', self.VendorAny.name, label="Vendor (any)")
|
||||
# factory=VendorAnyFilter, joiner=join_vendor_any)
|
||||
|
||||
g.default_sortkey = 'description'
|
||||
g.default_sortkey = 'upc'
|
||||
|
||||
product_link = lambda p: self.get_action_url('view', p)
|
||||
|
||||
g.upc.set(renderer=forms.renderers.GPCFieldRenderer)
|
||||
g.upc.attrs(link=product_link)
|
||||
|
||||
g.description.set(renderer=DescriptionFieldRenderer)
|
||||
g.description.attrs(link=product_link)
|
||||
|
||||
g.regular_price.set(renderer=forms.renderers.PriceFieldRenderer)
|
||||
g.current_price.set(renderer=forms.renderers.PriceFieldRenderer)
|
||||
g.configure(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue