Changeset d0e7f7d in tailbone


Ignore:
Timestamp:
08/09/2020 03:50:25 PM (3 years ago)
Author:
Lance Edgar <lance@…>
Branches:
master
Children:
dca890f
Parents:
b4ea148
Message:

Improve rendering of true_margin column for pricing batch row grid

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tailbone/views/batch/pricing.py

    rb4ea148 rd0e7f7d  
    2626
    2727from __future__ import unicode_literals, absolute_import
     28
     29import six
    2830
    2931from rattail.db import model
     
    204206        g.set_renderer('current_price', self.render_current_price)
    205207
     208        g.set_renderer('true_margin', self.render_true_margin)
     209
    206210    def render_vendor_id(self, row, field):
    207211        vendor_id = row.vendor.id if row.vendor else None
     
    209213            return ""
    210214        return vendor_id
     215
     216    def render_true_margin(self, row, field):
     217        margin = row.true_margin
     218        if margin:
     219            margin = six.text_type(margin)
     220        else:
     221            margin = HTML.literal('&nbsp;')
     222        if row.old_true_margin is not None:
     223            title = "WAS: {}".format(row.old_true_margin)
     224        else:
     225            title = "WAS: NULL"
     226        return HTML.tag('span', title=title, c=[margin])
    211227
    212228    def row_grid_extra_class(self, row, i):
Note: See TracChangeset for help on using the changeset viewer.