diff --git a/rowers/templates/instroke_interactive.html b/rowers/templates/instroke_interactive.html index 953052b1..31290ff5 100644 --- a/rowers/templates/instroke_interactive.html +++ b/rowers/templates/instroke_interactive.html @@ -4,32 +4,77 @@ {% block title %}Advanced Features {% endblock %} +{% block scripts %} + + +{% endblock %} + {% block main %} -{{ js_res | safe }} -{{ css_res| safe }} - + -{{ the_script |safe }} +
+ {{ the_script |safe }} +

In Stroke Metrics

  • -
    +
    {{ the_div|safe }}
  • -
    + {% csrf_token %} {{ form.as_table }}
    - +
diff --git a/rowers/views/workoutviews.py b/rowers/views/workoutviews.py index 2fee1511..cc3964a8 100644 --- a/rowers/views/workoutviews.py +++ b/rowers/views/workoutviews.py @@ -2916,7 +2916,10 @@ def instroke_chart(request, id=0, metric=''): # pragma: no cover return HttpResponseRedirect(url) @permission_required('workout.change_workout', fn=get_workout_by_opaqueid, raise_exception=True) -def instroke_chart_interactive(request, id=0): # pragma: no cover +def instroke_chart_interactive(request, id=0): + + is_ajax = request_is_ajax(request) + w = get_workoutuser(id, request) rowdata = rrdata(csvfile=w.csvfilename) @@ -2925,7 +2928,11 @@ def instroke_chart_interactive(request, id=0): # pragma: no cover form = InstrokeForm(choices=instrokemetrics) script = '' - div = '' + div = get_call() + + metric = instrokemetrics[0] + spm_min = 15 + spm_max = 45 if request.method == 'POST': form = InstrokeForm(request.POST,choices=instrokemetrics) @@ -2933,12 +2940,16 @@ def instroke_chart_interactive(request, id=0): # pragma: no cover metric = form.cleaned_data['metric'] spm_min = form.cleaned_data['spm_min'] spm_max = form.cleaned_data['spm_max'] - data = rowdata.get_instroke_data(metric, - spm_min=spm_min, - spm_max=spm_max) - script, div = instroke_interactive_chart(data, metric, w, - spm_min, - spm_max) + + + data = rowdata.get_instroke_data(metric, + spm_min=spm_min, + spm_max=spm_max) + + script, div = instroke_interactive_chart(data, metric, w, + spm_min, + spm_max) + breadcrumbs = [ { @@ -2956,6 +2967,14 @@ def instroke_chart_interactive(request, id=0): # pragma: no cover ] + if is_ajax: + response = json.dumps({ + 'script': script, + 'div': div, + }) + + return HttpResponse(response, content_type='application/json') + return render(request, 'instroke_interactive.html', { @@ -2970,6 +2989,7 @@ def instroke_chart_interactive(request, id=0): # pragma: no cover 'the_div': div, }) + # erase column @permission_required('workout.change_workout', fn=get_workout_by_opaqueid, raise_exception=True) def workout_erase_column_view(request, id=0, column=''):