diff --git a/tailbone/views/batch/pricing.py b/tailbone/views/batch/pricing.py index 6d947bc4..a378614c 100644 --- a/tailbone/views/batch/pricing.py +++ b/tailbone/views/batch/pricing.py @@ -28,8 +28,9 @@ from __future__ import unicode_literals, absolute_import from rattail.db import model -from tailbone import forms -from tailbone.views.batch import BatchMasterView3 as BatchMasterView +from webhelpers2.html import tags + +from tailbone.views.batch import BatchMasterView4 as BatchMasterView class PricingBatchView(BatchMasterView): @@ -73,6 +74,10 @@ class PricingBatchView(BatchMasterView): 'executed_by', ] + row_labels = { + 'upc': "UPC", + } + row_grid_columns = [ 'sequence', 'upc', @@ -88,6 +93,27 @@ class PricingBatchView(BatchMasterView): 'status_code', ] + row_form_fields = [ + 'sequence', + 'product', + 'upc', + 'brand_name', + 'description', + 'size', + 'department_number', + 'department_name', + 'vendor', + 'regular_unit_cost', + 'discounted_unit_cost', + 'old_price', + 'new_price', + 'price_diff', + 'price_margin', + 'price_markup', + 'status_code', + 'status_text', + ] + def configure_row_grid(self, g): super(PricingBatchView, self).configure_row_grid(g) @@ -109,36 +135,24 @@ class PricingBatchView(BatchMasterView): if row.status_code in (row.STATUS_PRICE_INCREASE, row.STATUS_PRICE_DECREASE): return 'notice' - def _preconfigure_row_fieldset(self, fs): - super(PricingBatchView, self)._preconfigure_row_fieldset(fs) - fs.upc.set(label="UPC") - fs.vendor.set(renderer=forms.renderers.VendorFieldRenderer) - fs.old_price.set(renderer=forms.renderers.CurrencyFieldRenderer) - fs.new_price.set(renderer=forms.renderers.CurrencyFieldRenderer) - fs.price_diff.set(renderer=forms.renderers.CurrencyFieldRenderer) + def configure_row_form(self, f): + super(PricingBatchView, self).configure_row_form(f) - def configure_row_fieldset(self, fs): - fs.configure( - include=[ - fs.sequence, - fs.product, - fs.upc, - fs.brand_name, - fs.description, - fs.size, - fs.department_number, - fs.department_name, - fs.vendor, - fs.regular_unit_cost, - fs.discounted_unit_cost, - fs.old_price, - fs.new_price, - fs.price_diff, - fs.price_margin, - fs.price_markup, - fs.status_code, - fs.status_text, - ]) + # currency fields + f.set_type('old_price', 'currency') + f.set_type('new_price', 'currency') + f.set_type('price_diff', 'currency') + + # vendor + f.set_renderer('vendor', self.render_vendor) + + def render_vendor(self, row, field): + vendor = row.vendor + if not vendor: + return "" + text = "({}) {}".format(vendor.id, vendor.name) + url = self.request.route_url('vendors.view', uuid=vendor.uuid) + return tags.link_to(text, url) def includeme(config):