Improve rendering of true_margin
column for pricing batch row grid
This commit is contained in:
parent
b4ea1489a7
commit
d0e7f7dda2
|
@ -26,6 +26,8 @@ Views for pricing batches
|
|||
|
||||
from __future__ import unicode_literals, absolute_import
|
||||
|
||||
import six
|
||||
|
||||
from rattail.db import model
|
||||
from rattail.time import localtime
|
||||
|
||||
|
@ -203,12 +205,26 @@ class PricingBatchView(BatchMasterView):
|
|||
|
||||
g.set_renderer('current_price', self.render_current_price)
|
||||
|
||||
g.set_renderer('true_margin', self.render_true_margin)
|
||||
|
||||
def render_vendor_id(self, row, field):
|
||||
vendor_id = row.vendor.id if row.vendor else None
|
||||
if not vendor_id:
|
||||
return ""
|
||||
return vendor_id
|
||||
|
||||
def render_true_margin(self, row, field):
|
||||
margin = row.true_margin
|
||||
if margin:
|
||||
margin = six.text_type(margin)
|
||||
else:
|
||||
margin = HTML.literal(' ')
|
||||
if row.old_true_margin is not None:
|
||||
title = "WAS: {}".format(row.old_true_margin)
|
||||
else:
|
||||
title = "WAS: NULL"
|
||||
return HTML.tag('span', title=title, c=[margin])
|
||||
|
||||
def row_grid_extra_class(self, row, i):
|
||||
extra_class = None
|
||||
|
||||
|
|
Loading…
Reference in a new issue