Expose the productUser table data

just the basics for now...
This commit is contained in:
Lance Edgar 2020-12-09 13:11:42 -06:00
parent 5b48c44891
commit 6b423870eb
3 changed files with 89 additions and 1 deletions

View file

@ -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'):
<li>${h.link_to("View CORE-POS Products", url('corepos.products'))}</li>
% endif
</%def>
${parent.body()}

View file

@ -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'):
<li>${h.link_to("View CORE-POS Products User", url('corepos.products_user'))}</li>
% endif
</%def>
${parent.body()}

View file

@ -27,7 +27,7 @@ CORE-POS product views
from corepos.db.office_op import model as corepos from corepos.db.office_op import model as corepos
from corepos.db.util import table_exists from corepos.db.util import table_exists
from webhelpers2.html import HTML from webhelpers2.html import HTML, tags
from .master import CoreOfficeMasterView from .master import CoreOfficeMasterView
@ -115,6 +115,7 @@ class ProductView(CoreOfficeMasterView):
'start_date', 'start_date',
'end_date', 'end_date',
'created',
'modified', 'modified',
'discount', 'discount',
@ -169,6 +170,7 @@ class ProductView(CoreOfficeMasterView):
f.set_renderer('vendor_items', self.render_vendor_items) f.set_renderer('vendor_items', self.render_vendor_items)
f.set_renderer('flags', self.render_flags) 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('start_date', 'datetime_local')
f.set_type('end_date', 'datetime_local') f.set_type('end_date', 'datetime_local')
@ -208,6 +210,14 @@ class ProductView(CoreOfficeMasterView):
return HTML.tag('ul', c=items) 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): def render_vendor_items(self, product, field):
route_prefix = self.get_route_prefix() route_prefix = self.get_route_prefix()
permission_prefix = self.get_permission_prefix() permission_prefix = self.get_permission_prefix()
@ -298,6 +308,59 @@ class ProductView(CoreOfficeMasterView):
return data 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): class ProductFlagView(CoreOfficeMasterView):
""" """
Master view for product flags Master view for product flags
@ -320,4 +383,5 @@ class ProductFlagView(CoreOfficeMasterView):
def includeme(config): def includeme(config):
ProductView.defaults(config) ProductView.defaults(config)
ProductUserView.defaults(config)
ProductFlagView.defaults(config) ProductFlagView.defaults(config)