diff --git a/tailbone_corepos/templates/core-pos/products-user/index.mako b/tailbone_corepos/templates/core-pos/products-user/index.mako
new file mode 100644
index 0000000..9cfa018
--- /dev/null
+++ b/tailbone_corepos/templates/core-pos/products-user/index.mako
@@ -0,0 +1,12 @@
+## -*- coding: utf-8; -*-
+<%inherit file="/master/index.mako" />
+
+<%def name="context_menu_items()">
+ ${parent.context_menu_items()}
+ % if request.has_perm('corepos.products.list'):
+
${h.link_to("View CORE-POS Products", url('corepos.products'))}
+ % endif
+%def>
+
+
+${parent.body()}
diff --git a/tailbone_corepos/templates/core-pos/products/index.mako b/tailbone_corepos/templates/core-pos/products/index.mako
new file mode 100644
index 0000000..3ee78b0
--- /dev/null
+++ b/tailbone_corepos/templates/core-pos/products/index.mako
@@ -0,0 +1,12 @@
+## -*- coding: utf-8; -*-
+<%inherit file="/master/index.mako" />
+
+<%def name="context_menu_items()">
+ ${parent.context_menu_items()}
+ % if request.has_perm('corepos.products_user.list'):
+ ${h.link_to("View CORE-POS Products User", url('corepos.products_user'))}
+ % endif
+%def>
+
+
+${parent.body()}
diff --git a/tailbone_corepos/views/corepos/products.py b/tailbone_corepos/views/corepos/products.py
index 7af9724..f89af32 100644
--- a/tailbone_corepos/views/corepos/products.py
+++ b/tailbone_corepos/views/corepos/products.py
@@ -27,7 +27,7 @@ CORE-POS product views
from corepos.db.office_op import model as corepos
from corepos.db.util import table_exists
-from webhelpers2.html import HTML
+from webhelpers2.html import HTML, tags
from .master import CoreOfficeMasterView
@@ -115,6 +115,7 @@ class ProductView(CoreOfficeMasterView):
'start_date',
'end_date',
+ 'created',
'modified',
'discount',
@@ -169,6 +170,7 @@ class ProductView(CoreOfficeMasterView):
f.set_renderer('vendor_items', self.render_vendor_items)
f.set_renderer('flags', self.render_flags)
+ f.set_renderer('user_info', self.render_user_info)
f.set_type('start_date', 'datetime_local')
f.set_type('end_date', 'datetime_local')
@@ -208,6 +210,14 @@ class ProductView(CoreOfficeMasterView):
return HTML.tag('ul', c=items)
+ def render_user_info(self, product, field):
+ user_info = product.user_info
+ if not user_info:
+ return ""
+ text = str(user_info)
+ url = self.request.route_url('corepos.products_user.view', upc=user_info.upc)
+ return tags.link_to(text, url)
+
def render_vendor_items(self, product, field):
route_prefix = self.get_route_prefix()
permission_prefix = self.get_permission_prefix()
@@ -298,6 +308,59 @@ class ProductView(CoreOfficeMasterView):
return data
+class ProductUserView(CoreOfficeMasterView):
+ """
+ Master view for `productUser` table
+ """
+ model_class = corepos.ProductUser
+ model_title = "CORE-POS Product User"
+ model_title_plural = "CORE-POS Products User"
+ url_prefix = '/core-pos/products-user'
+ route_prefix = 'corepos.products_user'
+
+ labels = {
+ 'upc': "UPC",
+ }
+
+ grid_columns = [
+ 'upc',
+ 'description',
+ 'brand',
+ 'sizing',
+ 'enable_online',
+ 'sold_out',
+ ]
+
+ form_fields = [
+ 'upc',
+ 'product',
+ 'description',
+ 'brand',
+ 'sizing',
+ 'long_text',
+ 'photo',
+ 'enable_online',
+ 'sold_out',
+ ]
+
+ def configure_grid(self, g):
+ super(ProductUserView, self).configure_grid(g)
+
+ g.filters['upc'].default_active = True
+ g.filters['upc'].default_verb = 'contains'
+
+ g.set_sort_defaults('upc')
+
+ g.set_link('upc')
+ g.set_link('description')
+
+ def configure_form(self, f):
+ super(ProductUserView, self).configure_form(f)
+
+ f.set_type('long_text', 'text')
+ f.set_renderer('product', self.render_corepos_product)
+
+
class ProductFlagView(CoreOfficeMasterView):
"""
Master view for product flags
@@ -320,4 +383,5 @@ class ProductFlagView(CoreOfficeMasterView):
def includeme(config):
ProductView.defaults(config)
+ ProductUserView.defaults(config)
ProductFlagView.defaults(config)