Private
Public Access
1
0

power zones

This commit is contained in:
Sander Roosendaal
2016-11-09 00:00:13 +01:00
parent 48044108b2
commit cde106bb19
6 changed files with 62 additions and 11 deletions

View File

@@ -2830,6 +2830,50 @@ def workout_add_piechart_view(request,id):
url = "/rowers/workout/"+str(w.id)+"/edit"
return HttpResponseRedirect(url)
@login_required()
def workout_add_power_piechart_view(request,id):
w = Workout.objects.get(id=id)
if (checkworkoutuser(request.user,w)==False):
return HttpResponse("You are not allowed add plots to this workout")
else:
f1 = w.csvfilename[6:-4]
timestr = strftime("%Y%m%d-%H%M%S")
imagename = f1+timestr+'.png'
fullpathimagename = 'static/plots/'+imagename
u = request.user
r = Rower.objects.get(user=u)
hrpwrdata = {
'hrmax':r.max,
'hrut2':r.ut2,
'hrut1':r.ut1,
'hrat':r.at,
'hrtr':r.tr,
'hran':r.an,
'ftp':r.ftp,
}
# make plot - asynchronous task
plotnr = 13
if (w.workouttype=='water'):
plotnr = plotnr+3
if settings.DEBUG:
res = handle_makeplot.delay(f1,w.csvfilename,
w.name,hrpwrdata,plotnr,imagename)
else:
res = queue.enqueue(handle_makeplot,f1,w.csvfilename,
w.name,hrpwrdata,plotnr,imagename)
# i = GraphImage(workout=w,creationdatetime=datetime.datetime.now(),
# filename=fullpathimagename)
i = GraphImage(workout=w,creationdatetime=timezone.now(),
filename=fullpathimagename)
i.save()
url = "/rowers/workout/"+str(w.id)+"/edit"
return HttpResponseRedirect(url)
@login_required()
def workout_add_timeplot_view(request,id):
w = Workout.objects.get(id=id)