showing discounts
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -10,11 +10,19 @@
|
||||
|
||||
<ul class="main-content">
|
||||
<li class="grid_4">
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
{% if rower.eurocredits %}
|
||||
<p>
|
||||
<em>Your have discount vouchers for an mount of {{ rower.eurocredits }}€</em>. You
|
||||
will get discount for up to this amount on any paid plan.
|
||||
</p>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% for plan in plans %}
|
||||
<li class="rounder">
|
||||
@@ -34,6 +42,10 @@
|
||||
{% else %}
|
||||
<p>Price: {{ plan.price }}€</p>
|
||||
{% endif %}
|
||||
{% if rower.eurocredits and plan.price > 0 %}
|
||||
<p>Your discount: {{ plan.price|discount:rower }}€</p>
|
||||
<p>You pay: {{ plan.price|discounted:rower }}€</p>
|
||||
{% endif %}
|
||||
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
||||
@@ -52,6 +52,12 @@
|
||||
{% endif %}
|
||||
</th><td>{{ rower.planexpires }}</td>
|
||||
</tr>
|
||||
{% if rower.eurocredits %}
|
||||
<tr>
|
||||
<th>Discount voucher for training plans</th>
|
||||
<td>{{ rower.eurocredits }}€</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</table>
|
||||
{% csrf_token %}
|
||||
|
||||
@@ -19,6 +19,7 @@ from rowers.plannedsessions import (
|
||||
race_can_register, race_can_submit,race_rower_status
|
||||
)
|
||||
|
||||
from rowers import credits
|
||||
from rowers import c2stuff
|
||||
from rowers.c2stuff import c2_open
|
||||
from rowers.rower_rules import is_coach_user, is_workout_user, isplanmember,ispromember
|
||||
@@ -153,6 +154,15 @@ def weekbegin(nr):
|
||||
return True
|
||||
return False
|
||||
|
||||
@register.filter
|
||||
def discount(amount,rower):
|
||||
return credits.discount(amount,rower)
|
||||
|
||||
|
||||
@register.filter
|
||||
def discounted(amount,rower):
|
||||
return credits.discounted(amount,rower)
|
||||
|
||||
@register.filter
|
||||
def weekend(nr):
|
||||
week, day = divmod(nr,7)
|
||||
|
||||
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Binary file not shown.
Reference in New Issue
Block a user