diff --git a/tailbone/views/batch/core.py b/tailbone/views/batch/core.py index 402619b2..51ca6634 100644 --- a/tailbone/views/batch/core.py +++ b/tailbone/views/batch/core.py @@ -595,6 +595,9 @@ class BatchMasterView(MasterView): f.set_readonly('status_code') f.set_label('status_code', "Status") + # status text + f.set_readonly('status_text') + def configure_mobile_row_form(self, f): super(BatchMasterView, self).configure_mobile_row_form(f) diff --git a/tailbone/views/batch/pricing.py b/tailbone/views/batch/pricing.py index e871c3df..4ab42e70 100644 --- a/tailbone/views/batch/pricing.py +++ b/tailbone/views/batch/pricing.py @@ -138,6 +138,19 @@ class PricingBatchView(BatchMasterView): def configure_row_form(self, 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 f.set_type('old_price', 'currency') f.set_type('new_price', 'currency') diff --git a/tailbone/views/custorders/items.py b/tailbone/views/custorders/items.py index f4c540f0..da56e7de 100644 --- a/tailbone/views/custorders/items.py +++ b/tailbone/views/custorders/items.py @@ -28,11 +28,14 @@ from __future__ import unicode_literals, absolute_import import datetime +import six from sqlalchemy import orm from rattail.db import model from rattail.time import localtime +from webhelpers2.html import tags + from tailbone.views import MasterView from tailbone.util import raw_datetime @@ -166,14 +169,6 @@ class CustomerOrderItemsView(MasterView): url = self.request.route_url('custorders.view', uuid=order.uuid) 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): return self.Session.query(model.CustomerOrderItemEvent)\ .filter(model.CustomerOrderItemEvent.item == item)\ diff --git a/tailbone/views/master.py b/tailbone/views/master.py index a01454f4..06470529 100644 --- a/tailbone/views/master.py +++ b/tailbone/views/master.py @@ -731,6 +731,14 @@ class MasterView(View): return obj.upc.pretty() if obj.upc else '' 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): pass diff --git a/tailbone/views/purchases/core.py b/tailbone/views/purchases/core.py index 2878a461..bc39fc3e 100644 --- a/tailbone/views/purchases/core.py +++ b/tailbone/views/purchases/core.py @@ -318,15 +318,7 @@ class PurchaseView(MasterView): f.set_renderer('department', self.render_row_department) # product - f.set_renderer('product', self.render_row_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) + f.set_renderer('product', self.render_product) def render_row_department(self, row, field): return "{} {}".format(row.department_number, row.department_name) diff --git a/tailbone/views/purchasing/batch.py b/tailbone/views/purchasing/batch.py index ef105df7..e2b9e379 100644 --- a/tailbone/views/purchasing/batch.py +++ b/tailbone/views/purchasing/batch.py @@ -692,7 +692,7 @@ class PurchasingBatchView(BatchMasterView): f.set_readonly('upc') f.set_readonly('item_id') 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? # f.remove_fields('po_total', @@ -704,18 +704,10 @@ class PurchasingBatchView(BatchMasterView): f.remove_fields('brand_name', 'description', 'size') - f.set_renderer('product', self.render_row_product) + f.set_renderer('product', self.render_product) else: 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): super(PurchasingBatchView, self).configure_mobile_row_form(f) # row = f.model_instance diff --git a/tailbone/views/vendors/catalogs.py b/tailbone/views/vendors/catalogs.py index a3d0c43e..c8c5e30c 100644 --- a/tailbone/views/vendors/catalogs.py +++ b/tailbone/views/vendors/catalogs.py @@ -198,14 +198,6 @@ class VendorCatalogsView(FileBatchMasterView): super(VendorCatalogsView, self).configure_row_form(f) 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): parsers = self.get_parsers() for parser in parsers: