From 0fbe3380cdbe81edaa533ed08b482defa1f26b23 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 14 Jan 2020 16:45:08 -0600 Subject: [PATCH] Highlight SRP in red, if reg price is greater (in product view) --- tailbone/views/products.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tailbone/views/products.py b/tailbone/views/products.py index fae009e3..0b60e79d 100644 --- a/tailbone/views/products.py +++ b/tailbone/views/products.py @@ -487,7 +487,7 @@ class ProductsView(MasterView): if not text: return history - text = HTML.tag('span', c=text) + text = HTML.tag('span', c=[text]) br = HTML.tag('br') return HTML.tag('div', c=[text, br, history]) @@ -506,6 +506,13 @@ class ProductsView(MasterView): else: # not buefy return self.add_price_history_link(text, 'regular') + def warn_if_regprice_more_than_srp(self, product, text): + sugprice = product.suggested_price.price if product.suggested_price else None + regprice = product.regular_price.price if product.regular_price else None + if sugprice and regprice and sugprice > regprice: + return HTML.tag('span', style='color: red;', c=text) + return text + def render_suggested_price(self, product, column): text = self.render_price(product, column) @@ -515,6 +522,8 @@ class ProductsView(MasterView): date = localtime(self.rattail_config, history[0]['changed'], from_utc=True).date() text = "{} (as of {})".format(text, date) + text = self.warn_if_regprice_more_than_srp(product, text) + if self.get_use_buefy(): # TODO: should add history link here too... return text @@ -526,11 +535,7 @@ class ProductsView(MasterView): if not text: return "" - sugprice = product.suggested_price.price if product.suggested_price else None - regprice = product.regular_price.price if product.regular_price else None - if sugprice and regprice and sugprice < regprice: - return HTML.tag('div', style='color: red;', c=text) - + text = self.warn_if_regprice_more_than_srp(product, text) return text def render_true_cost(self, product, field):