Private
Public Access
1
0

static charts moved to uploads.py

This commit is contained in:
Sander Roosendaal
2017-09-25 13:21:13 +02:00
parent 00acc23259
commit 79b8d7b5e0
2 changed files with 21 additions and 172 deletions

View File

@@ -6647,167 +6647,6 @@ def workout_add_chart_view(request,id,plotnr=1):
url = "/rowers/workout/"+str(w.id)+"/edit"
return HttpResponseRedirect(url)
# Create the chart image with wind corrected pace (OTW)
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
def workout_add_otw_powerplot_view(request,id):
try:
w = Workout.objects.get(id=id)
except Workout.DoesNotExist:
raise Http404("Workout doesn't exist")
if (checkworkoutuser(request.user,w)==False):
raise PermissionDenied("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'
u = w.user.user
r = getrower(u)
title = w.name
res = uploads.make_plot(r,w,f1,w.csvfilename,'timeplot',title,plotnr=9,imagename=imagename)
url = "/rowers/workout/"+str(w.id)+"/edit"
return HttpResponseRedirect(url)
# Create the Heart rate zone pie chart
@login_required()
def workout_add_piechart_view(request,id):
try:
w = Workout.objects.get(id=id)
except Workout.DoesNotExist:
raise Http404("Workout doesn't exist")
if (checkworkoutuser(request.user,w)==False):
raise PermissionDenied("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 = w.user.user
r = getrower(u)
title = w.name
res = uploads.make_plot(r,w,f1,w.csvfilename,'pieplot',title,plotnr=3,imagename=imagename)
url = "/rowers/workout/"+str(w.id)+"/edit"
return HttpResponseRedirect(url)
# Create the Power zone pie chart
@login_required()
def workout_add_power_piechart_view(request,id):
try:
w = Workout.objects.get(id=id)
except Workout.DoesNotExist:
raise Http404("Workout doesn't exist")
if (checkworkoutuser(request.user,w)==False):
raise PermissionDenied("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 = w.user.user
r = getrower(u)
title = w.name
res = uploads.make_plot(r,w,f1,w.csvfilename,'pieplot',title,plotnr=13,imagename=imagename)
url = "/rowers/workout/"+str(w.id)+"/edit"
return HttpResponseRedirect(url)
# Create the time based summary chart
@login_required()
def workout_add_timeplot_view(request,id):
try:
w = Workout.objects.get(id=id)
except Workout.DoesNotExist:
raise Http404("Workout doesn't exist")
if (checkworkoutuser(request.user,w)==False):
raise PermissionDenied("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 = w.user.user
r = getrower(u)
title = w.name
res = uploads.make_plot(r,w,f1,w.csvfilename,'timeplot',title,plotnr=1,imagename=imagename)
url = "/rowers/workout/"+str(w.id)+"/edit"
return HttpResponseRedirect(url)
# Create the distance based summary chart
@login_required()
def workout_add_distanceplot_view(request,id):
try:
w = Workout.objects.get(id=id)
except Workout.DoesNotExist:
raise Http404("Workout doesn't exist")
if (checkworkoutuser(request.user,w)==False):
raise PermissionDenied("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 = w.user.user
r = getrower(u)
title = w.name
res = uploads.make_plot(r,w,f1,w.csvfilename,'distanceplot',title,plotnr=2,imagename=imagename)
url = "/rowers/workout/"+str(w.id)+"/edit"
return HttpResponseRedirect(url)
# Create the advanced parameters distance overview chart
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
def workout_add_distanceplot2_view(request,id):
try:
w = Workout.objects.get(id=id)
except Workout.DoesNotExist:
raise Http404("Workout doesn't exist")
if (checkworkoutuser(request.user,w)==False):
raise PermissionDenied("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 = w.user.user
r = getrower(u)
title = w.name
res = uploads.make_plot(r,w,f1,w.csvfilename,'distanceplot',title,plotnr=7,imagename=imagename)
url = "/rowers/workout/"+str(w.id)+"/edit"
return HttpResponseRedirect(url)
# Create the advanced parameters time based overview chart
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
def workout_add_timeplot2_view(request,id):
try:
w = Workout.objects.get(id=id)
except Workout.DoesNotExist:
raise Http404("Workout doesn't exist")
if (checkworkoutuser(request.user,w)==False):
raise PermissionDenied("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 = w.user.user
r = getrower(u)
title = w.name
res = uploads.make_plot(r,w,f1,w.csvfilename,'distanceplot',title,plotnr=8,imagename=imagename)
url = "/rowers/workout/"+str(w.id)+"/edit"
return HttpResponseRedirect(url)
# The page where you select which Strava workout to import
@login_required()