From 7f9648546d59bde96cb96269640c4c23fe1bccf7 Mon Sep 17 00:00:00 2001 From: JamesRamm Date: Sun, 6 Jan 2019 19:12:45 +0100 Subject: [PATCH] Product index with price --- docs/tutorial/products.md | 2 +- .../catalog/templates/catalog/product_index.html | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/tutorial/products.md b/docs/tutorial/products.md index 2b9380d..71c70b3 100644 --- a/docs/tutorial/products.md +++ b/docs/tutorial/products.md @@ -80,7 +80,7 @@ Finally, lets override the price getter to apply the discount: @ProductVariantBase.price.getter def price(self): if self.discount: - discount_price = self.base_price * Decimal(self.discount_percent / 100.0 ) + discount_price = self.base_price * Decimal((100 - self.discount_percent) / 100.0 ) return discount_price.quantize(Decimal('.01'), decimal.ROUND_HALF_UP) return self.base_price ``` diff --git a/longclaw/project_template/catalog/templates/catalog/product_index.html b/longclaw/project_template/catalog/templates/catalog/product_index.html index c1677a8..bd94418 100644 --- a/longclaw/project_template/catalog/templates/catalog/product_index.html +++ b/longclaw/project_template/catalog/templates/catalog/product_index.html @@ -10,12 +10,13 @@ {% templatetag openblock %} for post in page.get_children {% templatetag closeblock %} {% templatetag openblock %} with post=post.specific {% templatetag closeblock %}
- {% templatetag openblock %} image post.images.first.image max-500x320 {% templatetag closeblock %} + {% templatetag openblock %} image post.images.first.image max-400x320 {% templatetag closeblock %}

{% templatetag openvariable %} post.title {% templatetag closevariable %}

{% templatetag openvariable %} post.description|richtext {% templatetag closevariable %}

+

From €{% templatetag openvariable %} post.price_range.0 {% templatetag closevariable %}

{% templatetag openblock %} endwith {% templatetag closeblock %}