Private
Public Access
1
0

First version of gold medal chart

This commit is contained in:
Sander Roosendaal
2021-01-03 20:34:40 +01:00
parent f5ad179c3c
commit b84ba9d49a
4 changed files with 390 additions and 2 deletions

View File

@@ -1543,6 +1543,70 @@ def fitnessmetric_view(request,userid=0,mode='rower',
'form':form,
})
@user_passes_test(ispromember, login_url="/rowers/paidplans",
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
redirect_field_name=None)
def goldmedalscores_view(request,userid=0,
startdate=timezone.now()-timezone.timedelta(days=365),
enddate=timezone.now()):
is_ajax = False
if request.is_ajax():
is_ajax = True
therower = getrequestrower(request,userid=userid)
theuser = therower.user
if request.method == 'POST':
form = DateRangeForm(request.POST)
if form.is_valid():
startdate = form.cleaned_data['startdate']
enddate = form.cleaned_data['enddate']
if startdate > enddate:
s = enddate
enddate = startdate
startdate = s
else:
form = DateRangeForm(initial={
'startdate':startdate,
'enddate':enddate,
})
script, div = goldmedalscorechart(
theuser,startdate=startdate,enddate=enddate,
)
breadcrumbs = [
{
'url':'/rower/analysis',
'name':'Analysis',
},
{
'url':reverse(goldmedalscores_view),
'name': 'Gold Medal Scores'
}
]
if is_ajax:
response = json.dumps({
'script':script,
'div':div,
})
return(HttpResponse(response,content_type='application/json'))
return render(request,'goldmedalscores.html',
{
'rower':therower,
'active':'nav-analysis',
'chartscript':script,
'breadcrumbs':breadcrumbs,
'the_div':div,
'form':form,
})
@user_passes_test(ispromember, login_url="/rowers/paidplans",
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
redirect_field_name=None)
@@ -1606,8 +1670,8 @@ def performancemanager_view(request,userid=0,mode='rower',
'name':'Analysis'
},
{
'url':reverse('fitnessmetric_view'),
'name': 'Power Progress'
'url':reverse('performancemanager_view'),
'name': 'Performance Manager'
}
]