From 079ea6b2b893d5a0a751c12b6d29b321dd9368a7 Mon Sep 17 00:00:00 2001 From: Stephan Telling Date: Sun, 26 Mar 2017 13:57:00 +0200 Subject: [PATCH] add rough euro prices to the shop. fix #32 --- src/shop/templates/order_detail.html | 3 ++- src/shop/templates/product_detail.html | 3 ++- src/shop/templates/shop_index.html | 2 +- src/shop/templatetags/shop_tags.py | 9 +++++++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/shop/templates/order_detail.html b/src/shop/templates/order_detail.html index e1d90d72..72f2c925 100644 --- a/src/shop/templates/order_detail.html +++ b/src/shop/templates/order_detail.html @@ -62,7 +62,8 @@ Total - {{ order.total|currency }} + {{ order.total|currency }}
+ (~{{ order.total|approxeur }}) diff --git a/src/shop/templates/product_detail.html b/src/shop/templates/product_detail.html index 66429795..99301e27 100644 --- a/src/shop/templates/product_detail.html +++ b/src/shop/templates/product_detail.html @@ -20,7 +20,8 @@

Price
- {{ product.price|currency }} + {{ product.price|currency }}
+ ~{{ product.price|approxeur }}


diff --git a/src/shop/templates/shop_index.html b/src/shop/templates/shop_index.html index 1a3fb9fa..9ee0e1f0 100644 --- a/src/shop/templates/shop_index.html +++ b/src/shop/templates/shop_index.html @@ -57,7 +57,7 @@ Shop | {{ block.super }}
- {{ product.price|currency }} + {{ product.price|currency }} (~{{ product.price|approxeur }})
diff --git a/src/shop/templatetags/shop_tags.py b/src/shop/templatetags/shop_tags.py index 530445f5..7ca85fad 100644 --- a/src/shop/templatetags/shop_tags.py +++ b/src/shop/templatetags/shop_tags.py @@ -13,6 +13,15 @@ def currency(value): return False +@register.filter +def approxeur(value): + print(type(value)) + try: + return "{0:.2f} EUR".format(value / Decimal(7.5)) + except ValueError: + return False + + @register.filter() def truefalseicon(value): if value: