From db1f10368a340d370196bad73b272ff26403201c Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Thu, 11 Nov 2021 11:37:01 +0100 Subject: [PATCH] credits seem to work --- rowers/templates/buy_trainingplan.html | 4 ++++ rowers/templates/confirm_trainingplan.html | 6 +++--- rowers/templates/instantplan.html | 8 ++++++-- rowers/views/planviews.py | 3 ++- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/rowers/templates/buy_trainingplan.html b/rowers/templates/buy_trainingplan.html index 6be1d6bf..45594a78 100644 --- a/rowers/templates/buy_trainingplan.html +++ b/rowers/templates/buy_trainingplan.html @@ -21,6 +21,10 @@

Plan: {{ plan.name }}

Price: {{ plan.price }}€

+ {% if rower.eurocredits > 0 %} +

Your Discount: {{ plan.price|discount:rower }}

+

You will pay: {{ plan.price|discounted:rower }}

+ {% endif %}
  • diff --git a/rowers/templates/confirm_trainingplan.html b/rowers/templates/confirm_trainingplan.html index af325e53..de691f11 100644 --- a/rowers/templates/confirm_trainingplan.html +++ b/rowers/templates/confirm_trainingplan.html @@ -37,7 +37,7 @@ Plan{{ plan.name }} - Total€ {{ plan.price|currency }} + Total€ {{ plan.price|discounted:rower|currency }} @@ -70,7 +70,7 @@

    + value="{{ plan.price|discounted:rower }}" readonly>
    @@ -91,7 +91,7 @@ Policy and agree with the Terms of Service.

    {% csrf_token %} - +
  • diff --git a/rowers/templates/instantplan.html b/rowers/templates/instantplan.html index 5cfbe7fc..313d75d8 100644 --- a/rowers/templates/instantplan.html +++ b/rowers/templates/instantplan.html @@ -32,6 +32,10 @@ {% else %}

    Price: {{ plan.price }}€

    {% endif %} + {% if rower.eurocredits and plan.price > 0 %} +

    Your discount: {{ plan.price|discount:rower }}€

    +

    You pay: {{ plan.price|discounted:rower }}€

    + {% endif %}
  • {% if form %}
  • @@ -47,7 +51,7 @@ If you have set a training target, you can also ask to plan by that target. Select the target from the targets list, and select "plan by target".

    - {% if plan.price == 0 %} + {% if plan.price|discounted:rower == 0 %}
    {% else %} @@ -56,7 +60,7 @@ {{ form.as_table }} {% csrf_token %} - {% if plan.price == 0 %} + {% if plan.price|discounted:rower == 0 %}

    {% else %}

    diff --git a/rowers/views/planviews.py b/rowers/views/planviews.py index fccdf3f9..6a4f1f5a 100644 --- a/rowers/views/planviews.py +++ b/rowers/views/planviews.py @@ -9,6 +9,7 @@ import json from taggit.models import Tag import rowers.garmin_stuff as gs +from rowers import credits @login_required @permission_required('plannedsession.view_session',fn=get_session_by_pk,raise_exception=True) @@ -2575,7 +2576,7 @@ def rower_view_instantplan(request,id='',userid=0): raise Http404("Plan does not exist") plan = InstantPlan.objects.get(uuid=id) - + discountedprice = credits.discounted(plan.price,r) authorizationstring = 'Bearer '+settings.WORKOUTS_FIT_TOKEN url = settings.WORKOUTS_FIT_URL+"/trainingplan/"+id