diff --git a/rowers/credits.py b/rowers/credits.py index 30d7a279..e57710c9 100644 --- a/rowers/credits.py +++ b/rowers/credits.py @@ -1,4 +1,3 @@ -from rowers.models import Rower class InsufficientCreditError(Exception): """Raised when trying to subtract more than available""" @@ -24,3 +23,19 @@ def withdraw(amount, rower): return rower.eurocredits return rower.eurocredits + +def discount(amount,rower): + if amount < rower.eurocredits: + return amount + else: + return rower.eurocredits + + return 0 + +def discounted(amount,rower): + if amount > rower.eurocredits: + return amount-rower.eurocredits + else: + return 0 + + return 0 diff --git a/rowers/templates/instantplans.html b/rowers/templates/instantplans.html index 6176d9b9..2506fc8c 100644 --- a/rowers/templates/instantplans.html +++ b/rowers/templates/instantplans.html @@ -10,11 +10,19 @@
On this page, you find trusted training plans that work. If you are looking for a plan, this page is for you. This ever growing list of plans contains a plan for everyone, whether you are a beginning rower or experienced, irrespective of your current fitness level. Click on a plan to read more and see the sessions. If you're on a Self-Coach plan or higher, you can get the plan including even more detailed workout instructions copied straight to your training calendar on this site, with the simple click of a button. +
+ {% if rower.eurocredits %} ++ Your have discount vouchers for an mount of {{ rower.eurocredits }}€. You + will get discount for up to this amount on any paid plan. +
+ {% endif %}Price: {{ plan.price }}€
{% endif %} + {% if rower.eurocredits and plan.price > 0 %} +Your discount: {{ plan.price|discount:rower }}€
+You pay: {{ plan.price|discounted:rower }}€
+ {% endif %}