using uploads.make_plot in team_upload
This commit is contained in:
@@ -7581,56 +7581,9 @@ def team_workout_upload_view(request,message="",
|
||||
response = HttpResponseRedirect(url)
|
||||
w = Workout.objects.get(id=id)
|
||||
|
||||
if (make_plot):
|
||||
imagename = f1[:-4]+'.png'
|
||||
fullpathimagename = 'static/plots/'+imagename
|
||||
powerperc = 100*np.array([r.pw_ut2,
|
||||
r.pw_ut1,
|
||||
r.pw_at,
|
||||
r.pw_tr,r.pw_an])/r.ftp
|
||||
|
||||
ftp = float(r.ftp)
|
||||
if w.workouttype in ('water','coastal'):
|
||||
ftp = ftp*(100.-r.otwslack)/100.
|
||||
|
||||
hrpwrdata = {
|
||||
'hrmax':r.max,
|
||||
'hrut2':r.ut2,
|
||||
'hrut1':r.ut1,
|
||||
'hrat':r.at,
|
||||
'hrtr':r.tr,
|
||||
'hran':r.an,
|
||||
'ftp':ftp,
|
||||
'powerperc':serialize_list(powerperc),
|
||||
'powerzones':serialize_list(r.powerzones),
|
||||
}
|
||||
|
||||
# make plot - asynchronous task
|
||||
plotnrs = {
|
||||
'timeplot':1,
|
||||
'distanceplot':2,
|
||||
'pieplot':3,
|
||||
}
|
||||
|
||||
plotnr = plotnrs[plottype]
|
||||
if workouttype in ('water','coastal'):
|
||||
plotnr = plotnr+3
|
||||
|
||||
|
||||
if settings.DEBUG:
|
||||
res = handle_makeplot.delay(f1,f2,t,
|
||||
hrpwrdata,plotnr,
|
||||
imagename)
|
||||
else:
|
||||
res = queue.enqueue(handle_makeplot,f1,f2,
|
||||
t,hrpwrdata,
|
||||
plotnr,imagename)
|
||||
|
||||
|
||||
i = GraphImage(workout=w,
|
||||
creationdatetime=timezone.now(),
|
||||
filename=fullpathimagename)
|
||||
i.save()
|
||||
r = getrower(request.user)
|
||||
if (make_plot):
|
||||
id = uploads.make_plot(r,w,f1,f2,plottype,t)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user