diff --git a/rowers/templates/list_workouts.html b/rowers/templates/list_workouts.html index 4ce811c4..4776b86f 100644 --- a/rowers/templates/list_workouts.html +++ b/rowers/templates/list_workouts.html @@ -65,7 +65,10 @@

- + + {{ interactiveplot |safe }} diff --git a/rowers/templates/multicompare.html b/rowers/templates/multicompare.html index 774cd5ba..5e214ff1 100644 --- a/rowers/templates/multicompare.html +++ b/rowers/templates/multicompare.html @@ -15,28 +15,34 @@

Interactive Comparison

- +
    -
  • +
  • {{ the_div|safe }}
    - +
  • -
  • - - {% csrf_token %} - - {{ chartform.as_table }} -
    + +
  • + + {% csrf_token %} + + {{ chartform.as_table }} +
    +
  • +
  • + + {{ form.as_table }} +

    - +

    -
  • - -
+ + + {% endblock %} diff --git a/rowers/views/workoutviews.py b/rowers/views/workoutviews.py index 88d75939..955e6abe 100644 --- a/rowers/views/workoutviews.py +++ b/rowers/views/workoutviews.py @@ -1615,6 +1615,8 @@ def virtualevent_compare_view(request,id=0): workoutids = [result.workoutid for result in results] + + startenddict = {} if race.sessiontype == 'race': for result in results: @@ -1659,6 +1661,10 @@ def virtualevent_compare_view(request,id=0): except Workout.DoesNotExist: pass + form = WorkoutMultipleCompareForm() + form.fields["workouts"].queryset = Workout.objects.filter(id__in=workoutids) + form.fields["workouts"].initial = Workout.objects.filter(id__in=workoutids) + labeldict = { int(w.id): w.__str__() for w in workouts @@ -1674,7 +1680,25 @@ def virtualevent_compare_view(request,id=0): 'teamid':0 } ) + if request.method == 'POST' and 'workouts' in request.POST: + form = WorkoutMultipleCompareForm(request.POST) + form.fields["workouts"].queryset = Workout.objects.filter(id__in=workoutids) + chartform = ChartParamChoiceForm(request.POST) + if form.is_valid() and chartform.is_valid(): + cd = form.cleaned_data + workouts = cd['workouts'] + workoutids = [w.id for w in workouts] + xparam = chartform.cleaned_data['xparam'] + yparam = chartform.cleaned_data['yparam'] + plottype = chartform.cleaned_data['plottype'] + teamid = chartform.cleaned_data['teamid'] + ids = [int(w.id) for w in workouts] + request.session['ids'] = ids elif request.method == 'POST': + form = WorkoutMultipleCompareForm() + form.fields["workouts"].queryset = Workout.objects.filter(id__in=workoutids) + request.session['ids'] = workoutids + chartform = ChartParamChoiceForm(request.POST) if chartform.is_valid(): xparam = chartform.cleaned_data['xparam'] @@ -1686,7 +1710,6 @@ def virtualevent_compare_view(request,id=0): except KeyError: pass - request.session['ids'] = workoutids workouts = [] for id in workoutids: try: @@ -1695,11 +1718,9 @@ def virtualevent_compare_view(request,id=0): except Workout.DoesNotExist: pass - labeldict = { - int(w.id): w.__str__() for w in workouts - } - else: - raise HttpResponse('Only GET and POST allowed',status=405) + labeldict = { + int(w.id): w.__str__() for w in workouts + } res = interactive_multiple_compare_chart(workoutids,xparam,yparam, @@ -1747,6 +1768,7 @@ def virtualevent_compare_view(request,id=0): 'promember':promember, 'teamid':0, 'chartform':chartform, + 'form':form, 'teams':[] })