ajax calls working
This commit is contained in:
@@ -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=''):
|
||||
|
||||
Reference in New Issue
Block a user