Refactor pricing batch views per master4
This commit is contained in:
parent
e78d1ac3c1
commit
38afb35b65
|
@ -28,8 +28,9 @@ from __future__ import unicode_literals, absolute_import
|
||||||
|
|
||||||
from rattail.db import model
|
from rattail.db import model
|
||||||
|
|
||||||
from tailbone import forms
|
from webhelpers2.html import tags
|
||||||
from tailbone.views.batch import BatchMasterView3 as BatchMasterView
|
|
||||||
|
from tailbone.views.batch import BatchMasterView4 as BatchMasterView
|
||||||
|
|
||||||
|
|
||||||
class PricingBatchView(BatchMasterView):
|
class PricingBatchView(BatchMasterView):
|
||||||
|
@ -73,6 +74,10 @@ class PricingBatchView(BatchMasterView):
|
||||||
'executed_by',
|
'executed_by',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
row_labels = {
|
||||||
|
'upc': "UPC",
|
||||||
|
}
|
||||||
|
|
||||||
row_grid_columns = [
|
row_grid_columns = [
|
||||||
'sequence',
|
'sequence',
|
||||||
'upc',
|
'upc',
|
||||||
|
@ -88,6 +93,27 @@ class PricingBatchView(BatchMasterView):
|
||||||
'status_code',
|
'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):
|
def configure_row_grid(self, g):
|
||||||
super(PricingBatchView, self).configure_row_grid(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):
|
if row.status_code in (row.STATUS_PRICE_INCREASE, row.STATUS_PRICE_DECREASE):
|
||||||
return 'notice'
|
return 'notice'
|
||||||
|
|
||||||
def _preconfigure_row_fieldset(self, fs):
|
def configure_row_form(self, f):
|
||||||
super(PricingBatchView, self)._preconfigure_row_fieldset(fs)
|
super(PricingBatchView, self).configure_row_form(f)
|
||||||
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_fieldset(self, fs):
|
# currency fields
|
||||||
fs.configure(
|
f.set_type('old_price', 'currency')
|
||||||
include=[
|
f.set_type('new_price', 'currency')
|
||||||
fs.sequence,
|
f.set_type('price_diff', 'currency')
|
||||||
fs.product,
|
|
||||||
fs.upc,
|
# vendor
|
||||||
fs.brand_name,
|
f.set_renderer('vendor', self.render_vendor)
|
||||||
fs.description,
|
|
||||||
fs.size,
|
def render_vendor(self, row, field):
|
||||||
fs.department_number,
|
vendor = row.vendor
|
||||||
fs.department_name,
|
if not vendor:
|
||||||
fs.vendor,
|
return ""
|
||||||
fs.regular_unit_cost,
|
text = "({}) {}".format(vendor.id, vendor.name)
|
||||||
fs.discounted_unit_cost,
|
url = self.request.route_url('vendors.view', uuid=vendor.uuid)
|
||||||
fs.old_price,
|
return tags.link_to(text, url)
|
||||||
fs.new_price,
|
|
||||||
fs.price_diff,
|
|
||||||
fs.price_margin,
|
|
||||||
fs.price_markup,
|
|
||||||
fs.status_code,
|
|
||||||
fs.status_text,
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
def includeme(config):
|
def includeme(config):
|
||||||
|
|
Loading…
Reference in a new issue