From f807396b0a60cd5b009ebaadd9e02f35941efcd5 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Mon, 22 Mar 2021 19:59:32 +0100 Subject: [PATCH] completing plan implementation form --- rowers/plannedsessions.py | 10 ++++++++- rowers/templates/instantplan.html | 37 ++++++++++++++++--------------- rowers/views/planviews.py | 7 ++++++ 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py index c69d530d..8db47a02 100644 --- a/rowers/plannedsessions.py +++ b/rowers/plannedsessions.py @@ -1056,11 +1056,19 @@ def create_sessions_from_json(plansteps,athletes,startdate,manager): trainingdays = plansteps['trainingDays'] for day in trainingdays: for workout in day['workouts']: + print(workout['sport']) + print(mytypes.fitmappinginv[workout['sport'].lower()]) + sessionsport = 'water' + try: + sessionsport = mytypes.fitmappinginv[workout['sport'].lower()] + except KeyError: + pass + ps = PlannedSession( startdate = startdate+timedelta(days=day['order']), enddate = startdate, preferreddate = startdate, - sessionsport = 'water', # change this + sessionsport = sessionsport, # change this name = workout['workoutName'], steps = workout, manager = manager, diff --git a/rowers/templates/instantplan.html b/rowers/templates/instantplan.html index df55e69a..0295251a 100644 --- a/rowers/templates/instantplan.html +++ b/rowers/templates/instantplan.html @@ -9,7 +9,7 @@

{{ plan.name }}

    -
  • +
  • Created by: {{ plan.owner.first_name }} {{ plan.owner.last_name }}

    {% if plan.url %}

    Link: @@ -23,7 +23,25 @@

    {{ plan.hoursperweek }} hours per week

    {{ plan.sessionsperweek }} sessions per week

  • +
  • +

    + When you submit this form, a training plan will be created based on {{ plan.name }}, ending at your target date, + and the sessions will be copied to your session calendar. +

    +

    + You can select the end date manually or use the training target (if you have any), and the plan will start at + the date it needs to complete in time. +

    +
    + + {{ form.as_table }} +
    + {% csrf_token %} +

    +
    +
  • +

    Plan Details

    @@ -58,23 +76,6 @@
  • -
  • -

    - When you submit this form, a training plan will be created based on {{ plan.name }}, ending at your target date, - and the sessions will be copied to your session calendar. -

    -

    - You can select the end date manually or use the training target (if you have any), and the plan will start at - the date it needs to complete in time. -

    -
    - - {{ form.as_table }} -
    - {% csrf_token %} -

    -
    -
{% endblock %} diff --git a/rowers/views/planviews.py b/rowers/views/planviews.py index 1e5d8898..221ff5e5 100644 --- a/rowers/views/planviews.py +++ b/rowers/views/planviews.py @@ -2567,6 +2567,13 @@ def rower_view_instantplan(request,id='',userid=0): create_sessions_from_json(plansteps,athletes,startdate,r.user) + url = reverse('plannedsessions_view') + timeperiod = startdate.strftime('%Y-%m-%d')+'/'+enddate.strftime('%Y-%m-%d') + url = url+'?when='+timeperiod + + return HttpResponseRedirect(url) + + else: form = TrainingPlanForm(targets=targets,initial={'status':True,'rowers':[r]}, user=request.user)