Refactor label batch views per master4

This commit is contained in:
Lance Edgar 2018-02-04 10:58:30 -06:00
parent 88fe195615
commit 0737faa034

View file

@ -30,7 +30,7 @@ from rattail.db import model
from webhelpers2.html import HTML, tags from webhelpers2.html import HTML, tags
from tailbone.views.batch import BatchMasterView3 as BatchMasterView from tailbone.views.batch import BatchMasterView4 as BatchMasterView
class LabelBatchView(BatchMasterView): class LabelBatchView(BatchMasterView):
@ -76,6 +76,37 @@ class LabelBatchView(BatchMasterView):
'executed_by', 'executed_by',
] ]
row_labels = {
'upc': "UPC",
'vendor_id': "Vendor ID",
'label_profile': "Label Type",
}
row_form_fields = [
'sequence',
'upc',
'product',
'brand_name',
'description',
'size',
'department_number',
'department_name',
'regular_price',
'pack_quantity',
'pack_price',
'sale_price',
'sale_start',
'sale_stop',
'vendor_id',
'vendor_name',
'vendor_item_code',
'case_quantity',
'label_profile',
'label_quantity',
'status_code',
'status_text',
]
def configure_form(self, f): def configure_form(self, f):
super(LabelBatchView, self).configure_form(f) super(LabelBatchView, self).configure_form(f)
@ -98,82 +129,57 @@ class LabelBatchView(BatchMasterView):
def configure_row_grid(self, g): def configure_row_grid(self, g):
super(LabelBatchView, self).configure_row_grid(g) super(LabelBatchView, self).configure_row_grid(g)
g.set_label('upc', "UPC")
# short labels
g.set_label('brand_name', "Brand") g.set_label('brand_name', "Brand")
g.set_label('regular_price', "Reg Price") g.set_label('regular_price', "Reg Price")
g.set_label('label_profile', "Label Type")
g.set_label('label_quantity', "Qty") g.set_label('label_quantity', "Qty")
def row_grid_extra_class(self, row, i): def row_grid_extra_class(self, row, i):
if row.status_code != row.STATUS_OK: if row.status_code != row.STATUS_OK:
return 'warning' return 'warning'
def _preconfigure_row_fieldset(self, fs): def configure_row_form(self, f):
fs.sequence.set(readonly=True) super(LabelBatchView, self).configure_row_form(f)
fs.product.set(readonly=True)
fs.upc.set(readonly=True, label="UPC")
fs.brand_name.set(readonly=True)
fs.description.set(readonly=True)
fs.size.set(readonly=True)
fs.department_number.set(readonly=True)
fs.department_name.set(readonly=True)
fs.regular_price.set(readonly=True)
fs.pack_quantity.set(readonly=True)
fs.pack_price.set(readonly=True)
fs.sale_price.set(readonly=True)
fs.sale_start.set(readonly=True)
fs.sale_stop.set(readonly=True)
fs.vendor_id.set(readonly=True, label="Vendor ID")
fs.vendor_name.set(readonly=True)
fs.vendor_item_code.set(readonly=True)
fs.case_quantity.set(readonly=True)
fs.status_code.set(readonly=True)
fs.status_text.set(readonly=True)
fs.label_profile.set(label="Label Type") # readonly fields
f.set_readonly('sequence')
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('regular_price')
f.set_readonly('pack_quantity')
f.set_readonly('pack_price')
f.set_readonly('sale_price')
f.set_readonly('sale_start')
f.set_readonly('sale_stop')
f.set_readonly('vendor_id')
f.set_readonly('vendor_name')
f.set_readonly('vendor_item_code')
f.set_readonly('case_quantity')
f.set_readonly('status_code')
f.set_readonly('status_text')
def configure_row_fieldset(self, fs): if self.editing:
if self.viewing: f.remove_fields(
fs.configure( 'brand_name',
include=[ 'description',
fs.sequence, 'size',
fs.upc, 'pack_quantity',
fs.brand_name, 'pack_price',
fs.description, 'sale_start',
fs.size, 'sale_stop',
fs.department_number, 'vendor_id',
fs.department_name, 'vendor_name',
fs.regular_price, 'vendor_item_code',
fs.pack_quantity, 'case_quantity',
fs.pack_price, )
fs.sale_price, else:
fs.sale_start, f.remove_field('product')
fs.sale_stop,
fs.vendor_id,
fs.vendor_name,
fs.vendor_item_code,
fs.case_quantity,
fs.label_profile,
fs.label_quantity,
fs.status_code,
fs.status_text,
])
elif self.editing:
fs.configure(
include=[
fs.sequence,
fs.upc,
fs.product,
fs.department_number,
fs.department_name,
fs.regular_price,
fs.sale_price,
fs.label_profile,
fs.label_quantity,
fs.status_code,
fs.status_text,
])
def includeme(config): def includeme(config):