Add MasterView.render_product()
, fix edit for pricing batch row
This commit is contained in:
parent
b9da7e1b12
commit
2bd107056c
|
@ -595,6 +595,9 @@ class BatchMasterView(MasterView):
|
||||||
f.set_readonly('status_code')
|
f.set_readonly('status_code')
|
||||||
f.set_label('status_code', "Status")
|
f.set_label('status_code', "Status")
|
||||||
|
|
||||||
|
# status text
|
||||||
|
f.set_readonly('status_text')
|
||||||
|
|
||||||
def configure_mobile_row_form(self, f):
|
def configure_mobile_row_form(self, f):
|
||||||
super(BatchMasterView, self).configure_mobile_row_form(f)
|
super(BatchMasterView, self).configure_mobile_row_form(f)
|
||||||
|
|
||||||
|
|
|
@ -138,6 +138,19 @@ class PricingBatchView(BatchMasterView):
|
||||||
def configure_row_form(self, f):
|
def configure_row_form(self, f):
|
||||||
super(PricingBatchView, self).configure_row_form(f)
|
super(PricingBatchView, self).configure_row_form(f)
|
||||||
|
|
||||||
|
# readonly fields
|
||||||
|
f.set_readonly('product')
|
||||||
|
f.set_readonly('upc')
|
||||||
|
f.set_readonly('brand_name')
|
||||||
|
f.set_readonly('description')
|
||||||
|
f.set_readonly('size')
|
||||||
|
f.set_readonly('department_number')
|
||||||
|
f.set_readonly('department_name')
|
||||||
|
f.set_readonly('vendor')
|
||||||
|
|
||||||
|
# product
|
||||||
|
f.set_renderer('product', self.render_product)
|
||||||
|
|
||||||
# currency fields
|
# currency fields
|
||||||
f.set_type('old_price', 'currency')
|
f.set_type('old_price', 'currency')
|
||||||
f.set_type('new_price', 'currency')
|
f.set_type('new_price', 'currency')
|
||||||
|
|
|
@ -28,11 +28,14 @@ from __future__ import unicode_literals, absolute_import
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
import six
|
||||||
from sqlalchemy import orm
|
from sqlalchemy import orm
|
||||||
|
|
||||||
from rattail.db import model
|
from rattail.db import model
|
||||||
from rattail.time import localtime
|
from rattail.time import localtime
|
||||||
|
|
||||||
|
from webhelpers2.html import tags
|
||||||
|
|
||||||
from tailbone.views import MasterView
|
from tailbone.views import MasterView
|
||||||
from tailbone.util import raw_datetime
|
from tailbone.util import raw_datetime
|
||||||
|
|
||||||
|
@ -166,14 +169,6 @@ class CustomerOrderItemsView(MasterView):
|
||||||
url = self.request.route_url('custorders.view', uuid=order.uuid)
|
url = self.request.route_url('custorders.view', uuid=order.uuid)
|
||||||
return tags.link_to(text, url)
|
return tags.link_to(text, url)
|
||||||
|
|
||||||
def render_product(self, order, field):
|
|
||||||
product = order.product
|
|
||||||
if not product:
|
|
||||||
return ""
|
|
||||||
text = six.text_type(product)
|
|
||||||
url = self.request.route_url('products.view', uuid=product.uuid)
|
|
||||||
return tags.link_to(text, url)
|
|
||||||
|
|
||||||
def get_row_data(self, item):
|
def get_row_data(self, item):
|
||||||
return self.Session.query(model.CustomerOrderItemEvent)\
|
return self.Session.query(model.CustomerOrderItemEvent)\
|
||||||
.filter(model.CustomerOrderItemEvent.item == item)\
|
.filter(model.CustomerOrderItemEvent.item == item)\
|
||||||
|
|
|
@ -731,6 +731,14 @@ class MasterView(View):
|
||||||
return obj.upc.pretty() if obj.upc else ''
|
return obj.upc.pretty() if obj.upc else ''
|
||||||
return getattr(obj, product_key)
|
return getattr(obj, product_key)
|
||||||
|
|
||||||
|
def render_product(self, obj, field):
|
||||||
|
product = getattr(obj, field)
|
||||||
|
if not product:
|
||||||
|
return ""
|
||||||
|
text = six.text_type(product)
|
||||||
|
url = self.request.route_url('products.view', uuid=product.uuid)
|
||||||
|
return tags.link_to(text, url)
|
||||||
|
|
||||||
def before_create_flush(self, obj, form):
|
def before_create_flush(self, obj, form):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -318,15 +318,7 @@ class PurchaseView(MasterView):
|
||||||
f.set_renderer('department', self.render_row_department)
|
f.set_renderer('department', self.render_row_department)
|
||||||
|
|
||||||
# product
|
# product
|
||||||
f.set_renderer('product', self.render_row_product)
|
f.set_renderer('product', self.render_product)
|
||||||
|
|
||||||
def render_row_product(self, row, field):
|
|
||||||
product = row.product
|
|
||||||
if not product:
|
|
||||||
return ""
|
|
||||||
text = six.text_type(product)
|
|
||||||
url = self.request.route_url('products.view', uuid=product.uuid)
|
|
||||||
return tags.link_to(text, url)
|
|
||||||
|
|
||||||
def render_row_department(self, row, field):
|
def render_row_department(self, row, field):
|
||||||
return "{} {}".format(row.department_number, row.department_name)
|
return "{} {}".format(row.department_number, row.department_name)
|
||||||
|
|
|
@ -692,7 +692,7 @@ class PurchasingBatchView(BatchMasterView):
|
||||||
f.set_readonly('upc')
|
f.set_readonly('upc')
|
||||||
f.set_readonly('item_id')
|
f.set_readonly('item_id')
|
||||||
f.set_readonly('product')
|
f.set_readonly('product')
|
||||||
f.set_renderer('product', self.render_row_product)
|
f.set_renderer('product', self.render_product)
|
||||||
|
|
||||||
# TODO: what's up with this again?
|
# TODO: what's up with this again?
|
||||||
# f.remove_fields('po_total',
|
# f.remove_fields('po_total',
|
||||||
|
@ -704,18 +704,10 @@ class PurchasingBatchView(BatchMasterView):
|
||||||
f.remove_fields('brand_name',
|
f.remove_fields('brand_name',
|
||||||
'description',
|
'description',
|
||||||
'size')
|
'size')
|
||||||
f.set_renderer('product', self.render_row_product)
|
f.set_renderer('product', self.render_product)
|
||||||
else:
|
else:
|
||||||
f.remove_field('product')
|
f.remove_field('product')
|
||||||
|
|
||||||
def render_row_product(self, row, field):
|
|
||||||
product = row.product
|
|
||||||
if not product:
|
|
||||||
return ""
|
|
||||||
text = six.text_type(product)
|
|
||||||
url = self.request.route_url('products.view', uuid=product.uuid)
|
|
||||||
return tags.link_to(text, url)
|
|
||||||
|
|
||||||
def configure_mobile_row_form(self, f):
|
def configure_mobile_row_form(self, f):
|
||||||
super(PurchasingBatchView, self).configure_mobile_row_form(f)
|
super(PurchasingBatchView, self).configure_mobile_row_form(f)
|
||||||
# row = f.model_instance
|
# row = f.model_instance
|
||||||
|
|
8
tailbone/views/vendors/catalogs.py
vendored
8
tailbone/views/vendors/catalogs.py
vendored
|
@ -198,14 +198,6 @@ class VendorCatalogsView(FileBatchMasterView):
|
||||||
super(VendorCatalogsView, self).configure_row_form(f)
|
super(VendorCatalogsView, self).configure_row_form(f)
|
||||||
f.set_renderer('product', self.render_product)
|
f.set_renderer('product', self.render_product)
|
||||||
|
|
||||||
def render_product(self, row, field):
|
|
||||||
product = row.product
|
|
||||||
if not product:
|
|
||||||
return ""
|
|
||||||
text = six.text_type(product)
|
|
||||||
url = self.request.route_url('products.view', uuid=product.uuid)
|
|
||||||
return tags.link_to(text, url)
|
|
||||||
|
|
||||||
def template_kwargs_create(self, **kwargs):
|
def template_kwargs_create(self, **kwargs):
|
||||||
parsers = self.get_parsers()
|
parsers = self.get_parsers()
|
||||||
for parser in parsers:
|
for parser in parsers:
|
||||||
|
|
Loading…
Reference in a new issue