Private
Public Access
1
0

Initial updates (rowerpowerform) and ftp everywhere rrower is called

This commit is contained in:
sanderroosendaal
2016-11-08 10:31:27 +01:00
parent 02a12585a2
commit 3444995880
8 changed files with 124 additions and 46 deletions

View File

@@ -73,7 +73,7 @@ def getrowdata(id=0):
rr = rrower(hrmax=r.max,hrut2=r.ut2, rr = rrower(hrmax=r.max,hrut2=r.ut2,
hrut1=r.ut1,hrat=r.at, hrut1=r.ut1,hrat=r.at,
hrtr=r.tr,hran=r.an) hrtr=r.tr,hran=r.an,ftp=r.ftp)
rowdata = rdata(f1,rower=rr) rowdata = rdata(f1,rower=rr)

View File

@@ -359,7 +359,7 @@ def interactive_windchart(id=0,promember=0):
rr = rrower(hrmax=r.max,hrut2=r.ut2, rr = rrower(hrmax=r.max,hrut2=r.ut2,
hrut1=r.ut1,hrat=r.at, hrut1=r.ut1,hrat=r.at,
hrtr=r.tr,hran=r.an) hrtr=r.tr,hran=r.an,ftp=r.ftp)
rowdata = rdata(f1,rower=rr) rowdata = rdata(f1,rower=rr)
if rowdata == 0: if rowdata == 0:
@@ -447,7 +447,7 @@ def interactive_streamchart(id=0,promember=0):
rr = rrower(hrmax=r.max,hrut2=r.ut2, rr = rrower(hrmax=r.max,hrut2=r.ut2,
hrut1=r.ut1,hrat=r.at, hrut1=r.ut1,hrat=r.at,
hrtr=r.tr,hran=r.an) hrtr=r.tr,hran=r.an,ftp=r.ftp)
rowdata = rdata(f1,rower=rr) rowdata = rdata(f1,rower=rr)
if rowdata == 0: if rowdata == 0:

View File

@@ -142,7 +142,7 @@ def make_new_workout_from_email(rr,f2,name,cntr=0):
# make workout and put in database # make workout and put in database
#r = rrower(hrmax=rr.max,hrut2=rr.ut2, #r = rrower(hrmax=rr.max,hrut2=rr.ut2,
# hrut1=rr.ut1,hrat=rr.at, # hrut1=rr.ut1,hrat=rr.at,
# hrtr=rr.tr,hran=rr.an) # hrtr=rr.tr,hran=rr.an,ftp=r.ftp)
row = rdata('media/'+f2) #,rower=r) row = rdata('media/'+f2) #,rower=r)
if row == 0: if row == 0:
return 0 return 0

View File

@@ -32,6 +32,8 @@ class Rower(models.Model):
weightcategory = models.CharField(default="hwt", weightcategory = models.CharField(default="hwt",
max_length=30, max_length=30,
choices=weightcategories) choices=weightcategories)
ftp = models.IntegerField(default=226,verbose_name="Functional Threshold Power")
c2token = models.CharField(default='',max_length=200,blank=True,null=True) c2token = models.CharField(default='',max_length=200,blank=True,null=True)
tokenexpirydate = models.DateTimeField(blank=True,null=True) tokenexpirydate = models.DateTimeField(blank=True,null=True)
@@ -49,7 +51,7 @@ class Rower(models.Model):
) )
rowerplan = models.CharField(default='basic',max_length=30, rowerplan = models.CharField(default='basic',max_length=30,
choices=plans) choices=plans)
friends = models.ManyToManyField("self") friends = models.ManyToManyField("self",blank=True)
team = models.ForeignKey(Team,blank=True,null=True) team = models.ForeignKey(Team,blank=True,null=True)
@@ -158,6 +160,10 @@ class AdvancedWorkoutForm(ModelForm):
model = Workout model = Workout
fields = ['boattype','weightvalue'] fields = ['boattype','weightvalue']
class RowerPowerForm(ModelForm):
class Meta:
model = Rower
fields = ['ftp']
class RowerForm(ModelForm): class RowerForm(ModelForm):
class Meta: class Meta:

View File

@@ -177,6 +177,8 @@ def handle_makeplot(f1,f2,t,hrdata,plotnr,imagename):
fig1 = row.get_timeplot_erg2(t) fig1 = row.get_timeplot_erg2(t)
elif (plotnr==9) or (plotnr==12): elif (plotnr==9) or (plotnr==12):
fig1 = row.get_time_otwpower(t) fig1 = row.get_time_otwpower(t)
elif (plotnr==13) or (plotnr==16):
fig1 = row.get_power_piechart(t)
canvas = FigureCanvas(fig1) canvas = FigureCanvas(fig1)

View File

@@ -9,7 +9,7 @@
</p> </p>
{% endif %} {% endif %}
<div class="grid_6 alpha"> <div class="grid_6 alpha">
<h1>Edit your Parameters</h1> <h1>Heart Rate Bands</h1>
<form enctype="multipart/form-data" action="" method="post"> <form enctype="multipart/form-data" action="" method="post">
<table> <table>
@@ -18,16 +18,21 @@
{% csrf_token %} {% csrf_token %}
<div class="grid_2 prefix_2 suffix_2"> <div class="grid_2 prefix_2 suffix_2">
<input class="button green" type="submit" value="Save"> <input class="button green" type="submit" value="Save">
</form>
</div> </div>
</div> </div>
<div class="grid_6 omega"> <div class="grid_6 omega">
<h1>Tokens etcetera</h1> <h1>Functional Threshold Power</h1>
<p> <p>
<form enctype="multipart/form-data" action="" method="post">
<table> <table>
<tr> {{ powerform.as_table }}
<th>Concept2 sync issues? Click:</th><td><a href="/rowers/me/c2refresh/"><img src="/static/img/blueC2logo.png" alt="Concept2 logo" width="140"></a></td>
</tr>
</table> </table>
{% csrf_token %}
<div class="grid_2 prefix_2 suffix_2">
<input class="button green" type="submit" value="Save">
</form>
</div>
</p> </p>
</div> </div>

View File

@@ -235,7 +235,7 @@ class DataTest(TestCase):
rr = rrower(hrmax=r.max,hrut2=r.ut2, rr = rrower(hrmax=r.max,hrut2=r.ut2,
hrut1=r.ut1,hrat=r.at, hrut1=r.ut1,hrat=r.at,
hrtr=r.tr,hran=r.an) hrtr=r.tr,hran=r.an,ftp=r.ftp)
row = rdata(filename,rower=rr) row = rdata(filename,rower=rr)
totaldist = row.df['cum_dist'].max() totaldist = row.df['cum_dist'].max()
totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min() totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min()
@@ -871,6 +871,7 @@ class PlotTests(TestCase):
'hrat':r.at, 'hrat':r.at,
'hrtr':r.tr, 'hrtr':r.tr,
'hran':r.an, 'hran':r.an,
'ftp':r.ftp,
} }
@@ -971,6 +972,16 @@ class PlotTests(TestCase):
filename=fullpathimagename) filename=fullpathimagename)
os.remove(fullpathimagename) os.remove(fullpathimagename)
plotnr = 13
if (w.workouttype=='water'):
plotnr = plotnr+3
res = handle_makeplot(f1,w.csvfilename,
w.name,self.hrdata,plotnr,imagename)
i = GraphImage(workout=w,creationdatetime=self.nu,
filename=fullpathimagename)
os.remove(fullpathimagename)
def test_otw_plots(self): def test_otw_plots(self):
w = self.wotw w = self.wotw
f1 = 'testdata.csv'[:-4] f1 = 'testdata.csv'[:-4]
@@ -1067,3 +1078,23 @@ class PlotTests(TestCase):
i = GraphImage(workout=w,creationdatetime=self.nu, i = GraphImage(workout=w,creationdatetime=self.nu,
filename=fullpathimagename) filename=fullpathimagename)
os.remove(fullpathimagename) os.remove(fullpathimagename)
plotnr = 9
if (w.workouttype=='water'):
plotnr = plotnr+3
res = handle_makeplot(f1,w.csvfilename,
w.name,self.hrdata,plotnr,imagename)
i = GraphImage(workout=w,creationdatetime=self.nu,
filename=fullpathimagename)
os.remove(fullpathimagename)
plotnr = 13
if (w.workouttype=='water'):
plotnr = plotnr+3
res = handle_makeplot(f1,w.csvfilename,
w.name,self.hrdata,plotnr,imagename)
i = GraphImage(workout=w,creationdatetime=self.nu,
filename=fullpathimagename)
os.remove(fullpathimagename)

View File

@@ -13,7 +13,8 @@ from django.core.mail import send_mail, BadHeaderError
from rowers.forms import EmailForm, RegistrationForm, RegistrationFormTermsOfService,RegistrationFormUniqueEmail,CNsummaryForm,UpdateWindForm,UpdateStreamForm from rowers.forms import EmailForm, RegistrationForm, RegistrationFormTermsOfService,RegistrationFormUniqueEmail,CNsummaryForm,UpdateWindForm,UpdateStreamForm
from rowers.forms import PredictedPieceForm,DateRangeForm,DeltaDaysForm from rowers.forms import PredictedPieceForm,DateRangeForm,DeltaDaysForm
from rowers.forms import SummaryStringForm,IntervalUpdateForm from rowers.forms import SummaryStringForm,IntervalUpdateForm
from rowers.models import Workout, User, Rower, WorkoutForm,RowerForm,GraphImage,AdvancedWorkoutForm from rowers.models import Workout, User, Rower, WorkoutForm
from rowers.models import RowerPowerForm,RowerForm,GraphImage,AdvancedWorkoutForm
import StringIO import StringIO
from django.contrib.auth.decorators import login_required,user_passes_test from django.contrib.auth.decorators import login_required,user_passes_test
from time import strftime,strptime,mktime,time,daylight from time import strftime,strptime,mktime,time,daylight
@@ -419,7 +420,7 @@ def add_workout_from_strokedata(user,importid,data,strokedata,source='c2'):
# make workout # make workout
rr = rrower(hrmax=r.max,hrut2=r.ut2, rr = rrower(hrmax=r.max,hrut2=r.ut2,
hrut1=r.ut1,hrat=r.at, hrut1=r.ut1,hrat=r.at,
hrtr=r.tr,hran=r.an) hrtr=r.tr,hran=r.an,ftp=r.ftp)
row = rdata(csvfilename,rower=rr) row = rdata(csvfilename,rower=rr)
totaldist = row.df['cum_dist'].max() totaldist = row.df['cum_dist'].max()
totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min() totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min()
@@ -647,7 +648,7 @@ def add_workout_from_stdata(user,importid,data):
# make workout # make workout
rr = rrower(hrmax=r.max,hrut2=r.ut2, rr = rrower(hrmax=r.max,hrut2=r.ut2,
hrut1=r.ut1,hrat=r.at, hrut1=r.ut1,hrat=r.at,
hrtr=r.tr,hran=r.an) hrtr=r.tr,hran=r.an,ftp=r.ftp)
row = rdata(csvfilename,rower=rr) row = rdata(csvfilename,rower=rr)
totaldist = row.df['cum_dist'].max() totaldist = row.df['cum_dist'].max()
totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min() totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min()
@@ -2752,13 +2753,14 @@ def workout_add_otw_powerplot_view(request,id):
fullpathimagename = 'static/plots/'+imagename fullpathimagename = 'static/plots/'+imagename
u = request.user u = request.user
r = Rower.objects.get(user=u) r = Rower.objects.get(user=u)
hrdata = { hrpwrdata = {
'hrmax':r.max, 'hrmax':r.max,
'hrut2':r.ut2, 'hrut2':r.ut2,
'hrut1':r.ut1, 'hrut1':r.ut1,
'hrat':r.at, 'hrat':r.at,
'hrtr':r.tr, 'hrtr':r.tr,
'hran':r.an, 'hran':r.an,
'ftp':r.ftp,
} }
# make plot - asynchronous task # make plot - asynchronous task
@@ -2769,10 +2771,10 @@ def workout_add_otw_powerplot_view(request,id):
if settings.DEBUG: if settings.DEBUG:
res = handle_makeplot.delay(f1,w.csvfilename, res = handle_makeplot.delay(f1,w.csvfilename,
w.name,hrdata,plotnr,imagename) w.name,hrpwrdata,plotnr,imagename)
else: else:
res = queue.enqueue(handle_makeplot,f1,w.csvfilename, res = queue.enqueue(handle_makeplot,f1,w.csvfilename,
w.name,hrdata,plotnr,imagename) w.name,hrpwrdata,plotnr,imagename)
# i = GraphImage(workout=w,creationdatetime=datetime.datetime.now(), # i = GraphImage(workout=w,creationdatetime=datetime.datetime.now(),
# filename=fullpathimagename) # filename=fullpathimagename)
@@ -2796,13 +2798,14 @@ def workout_add_piechart_view(request,id):
fullpathimagename = 'static/plots/'+imagename fullpathimagename = 'static/plots/'+imagename
u = request.user u = request.user
r = Rower.objects.get(user=u) r = Rower.objects.get(user=u)
hrdata = { hrpwrdata = {
'hrmax':r.max, 'hrmax':r.max,
'hrut2':r.ut2, 'hrut2':r.ut2,
'hrut1':r.ut1, 'hrut1':r.ut1,
'hrat':r.at, 'hrat':r.at,
'hrtr':r.tr, 'hrtr':r.tr,
'hran':r.an, 'hran':r.an,
'ftp':r.ftp,
} }
# make plot - asynchronous task # make plot - asynchronous task
@@ -2813,10 +2816,10 @@ def workout_add_piechart_view(request,id):
if settings.DEBUG: if settings.DEBUG:
res = handle_makeplot.delay(f1,w.csvfilename, res = handle_makeplot.delay(f1,w.csvfilename,
w.name,hrdata,plotnr,imagename) w.name,hrpwrdata,plotnr,imagename)
else: else:
res = queue.enqueue(handle_makeplot,f1,w.csvfilename, res = queue.enqueue(handle_makeplot,f1,w.csvfilename,
w.name,hrdata,plotnr,imagename) w.name,hrpwrdata,plotnr,imagename)
# i = GraphImage(workout=w,creationdatetime=datetime.datetime.now(), # i = GraphImage(workout=w,creationdatetime=datetime.datetime.now(),
# filename=fullpathimagename) # filename=fullpathimagename)
@@ -2839,13 +2842,14 @@ def workout_add_timeplot_view(request,id):
fullpathimagename = 'static/plots/'+imagename fullpathimagename = 'static/plots/'+imagename
u = request.user u = request.user
r = Rower.objects.get(user=u) r = Rower.objects.get(user=u)
hrdata = { hrpwrdata = {
'hrmax':r.max, 'hrmax':r.max,
'hrut2':r.ut2, 'hrut2':r.ut2,
'hrut1':r.ut1, 'hrut1':r.ut1,
'hrat':r.at, 'hrat':r.at,
'hrtr':r.tr, 'hrtr':r.tr,
'hran':r.an, 'hran':r.an,
'ftp':r.ftp,
} }
# make plot - asynchronous task # make plot - asynchronous task
@@ -2856,10 +2860,10 @@ def workout_add_timeplot_view(request,id):
if settings.DEBUG: if settings.DEBUG:
res = handle_makeplot.delay(f1,w.csvfilename, res = handle_makeplot.delay(f1,w.csvfilename,
w.name,hrdata,plotnr,imagename) w.name,hrpwrdata,plotnr,imagename)
else: else:
res = queue.enqueue(handle_makeplot,f1,w.csvfilename, res = queue.enqueue(handle_makeplot,f1,w.csvfilename,
w.name,hrdata,plotnr,imagename) w.name,hrpwrdata,plotnr,imagename)
i = GraphImage(workout=w,creationdatetime=timezone.now(), i = GraphImage(workout=w,creationdatetime=timezone.now(),
filename=fullpathimagename) filename=fullpathimagename)
@@ -2883,13 +2887,14 @@ def workout_add_distanceplot_view(request,id):
fullpathimagename = 'static/plots/'+imagename fullpathimagename = 'static/plots/'+imagename
u = request.user u = request.user
r = Rower.objects.get(user=u) r = Rower.objects.get(user=u)
hrdata = { hrpwrdata = {
'hrmax':r.max, 'hrmax':r.max,
'hrut2':r.ut2, 'hrut2':r.ut2,
'hrut1':r.ut1, 'hrut1':r.ut1,
'hrat':r.at, 'hrat':r.at,
'hrtr':r.tr, 'hrtr':r.tr,
'hran':r.an, 'hran':r.an,
'ftp':r.ftp,
} }
# make plot - asynchronous task # make plot - asynchronous task
@@ -2900,10 +2905,10 @@ def workout_add_distanceplot_view(request,id):
if settings.DEBUG: if settings.DEBUG:
res = handle_makeplot.delay(f1,w.csvfilename, res = handle_makeplot.delay(f1,w.csvfilename,
w.name,hrdata,plotnr,imagename) w.name,hrpwrdata,plotnr,imagename)
else: else:
res = queue.enqueue(handle_makeplot,f1,w.csvfilename, res = queue.enqueue(handle_makeplot,f1,w.csvfilename,
w.name,hrdata,plotnr,imagename) w.name,hrpwrdata,plotnr,imagename)
i = GraphImage(workout=w,creationdatetime=timezone.now(), i = GraphImage(workout=w,creationdatetime=timezone.now(),
filename=fullpathimagename) filename=fullpathimagename)
@@ -2926,7 +2931,7 @@ def workout_add_distanceplot2_view(request,id):
fullpathimagename = 'static/plots/'+imagename fullpathimagename = 'static/plots/'+imagename
u = request.user u = request.user
r = Rower.objects.get(user=u) r = Rower.objects.get(user=u)
hrdata = { hrpwrdata = {
'hrmax':r.max, 'hrmax':r.max,
'hrut2':r.ut2, 'hrut2':r.ut2,
'hrut1':r.ut1, 'hrut1':r.ut1,
@@ -2943,10 +2948,10 @@ def workout_add_distanceplot2_view(request,id):
if settings.DEBUG: if settings.DEBUG:
res = handle_makeplot.delay(f1,w.csvfilename, res = handle_makeplot.delay(f1,w.csvfilename,
w.name,hrdata,plotnr,imagename) w.name,hrpwrdata,plotnr,imagename)
else: else:
res = queue.enqueue(handle_makeplot,f1,w.csvfilename, res = queue.enqueue(handle_makeplot,f1,w.csvfilename,
w.name,hrdata,plotnr,imagename) w.name,hrpwrdata,plotnr,imagename)
i = GraphImage(workout=w,creationdatetime=timezone.now(), i = GraphImage(workout=w,creationdatetime=timezone.now(),
filename=fullpathimagename) filename=fullpathimagename)
@@ -2970,7 +2975,7 @@ def workout_add_timeplot2_view(request,id):
fullpathimagename = 'static/plots/'+imagename fullpathimagename = 'static/plots/'+imagename
u = request.user u = request.user
r = Rower.objects.get(user=u) r = Rower.objects.get(user=u)
hrdata = { hrpwrdata = {
'hrmax':r.max, 'hrmax':r.max,
'hrut2':r.ut2, 'hrut2':r.ut2,
'hrut1':r.ut1, 'hrut1':r.ut1,
@@ -2987,10 +2992,10 @@ def workout_add_timeplot2_view(request,id):
if settings.DEBUG: if settings.DEBUG:
res = handle_makeplot.delay(f1,w.csvfilename, res = handle_makeplot.delay(f1,w.csvfilename,
w.name,hrdata,plotnr,imagename) w.name,hrpwrdata,plotnr,imagename)
else: else:
res = queue.enqueue(handle_makeplot,f1,w.csvfilename, res = queue.enqueue(handle_makeplot,f1,w.csvfilename,
w.name,hrdata,plotnr,imagename) w.name,hrpwrdata,plotnr,imagename)
i = GraphImage(workout=w,creationdatetime=timezone.now(), i = GraphImage(workout=w,creationdatetime=timezone.now(),
filename=fullpathimagename) filename=fullpathimagename)
@@ -3335,7 +3340,7 @@ def workout_upload_view(request,message=""):
r = Rower.objects.get(user=request.user) r = Rower.objects.get(user=request.user)
rr = rrower(hrmax=r.max,hrut2=r.ut2, rr = rrower(hrmax=r.max,hrut2=r.ut2,
hrut1=r.ut1,hrat=r.at, hrut1=r.ut1,hrat=r.at,
hrtr=r.tr,hran=r.an) hrtr=r.tr,hran=r.an,ftp=r.ftp)
row = rdata(f2,rower=rr) row = rdata(f2,rower=rr)
if row == 0: if row == 0:
return HttpResponse("Error: CSV Data File Not Found") return HttpResponse("Error: CSV Data File Not Found")
@@ -3421,7 +3426,7 @@ def workout_upload_view(request,message=""):
imagename = f1[:-4]+'.png' imagename = f1[:-4]+'.png'
fullpathimagename = 'static/plots/'+imagename fullpathimagename = 'static/plots/'+imagename
u = request.user u = request.user
hrdata = { hrpwrdata = {
'hrmax':r.max, 'hrmax':r.max,
'hrut2':r.ut2, 'hrut2':r.ut2,
'hrut1':r.ut1, 'hrut1':r.ut1,
@@ -3443,14 +3448,14 @@ def workout_upload_view(request,message=""):
# res = handle_makeplot.delay(f1,f2,t, # res = handle_makeplot.delay(f1,f2,t,
# hrdata,plotnr,imagename) # hrpwrdata,plotnr,imagename)
if settings.DEBUG: if settings.DEBUG:
res = handle_makeplot.delay(f1,f2,t, res = handle_makeplot.delay(f1,f2,t,
hrdata,plotnr, hrpwrdata,plotnr,
imagename) imagename)
else: else:
res = queue.enqueue(handle_makeplot,f1,f2, res = queue.enqueue(handle_makeplot,f1,f2,
t,hrdata, t,hrpwrdata,
plotnr,imagename) plotnr,imagename)
@@ -3607,7 +3612,7 @@ def workout_upload_view_debug(request,message=""):
r = Rower.objects.get(user=request.user) r = Rower.objects.get(user=request.user)
rr = rrower(hrmax=r.max,hrut2=r.ut2, rr = rrower(hrmax=r.max,hrut2=r.ut2,
hrut1=r.ut1,hrat=r.at, hrut1=r.ut1,hrat=r.at,
hrtr=r.tr,hran=r.an) hrtr=r.tr,hran=r.an,ftp=r.ftp)
row = rdata(f2,rower=rr) row = rdata(f2,rower=rr)
if row == 0: if row == 0:
return HttpResponse("Error: CSV Data File Not Found") return HttpResponse("Error: CSV Data File Not Found")
@@ -3657,7 +3662,7 @@ def workout_upload_view_debug(request,message=""):
imagename = f1[:-4]+'.png' imagename = f1[:-4]+'.png'
fullpathimagename = 'static/plots/'+imagename fullpathimagename = 'static/plots/'+imagename
u = request.user u = request.user
hrdata = { hrpwrdata = {
'hrmax':r.max, 'hrmax':r.max,
'hrut2':r.ut2, 'hrut2':r.ut2,
'hrut1':r.ut1, 'hrut1':r.ut1,
@@ -3679,14 +3684,14 @@ def workout_upload_view_debug(request,message=""):
# res = handle_makeplot.delay(f1,f2,t, # res = handle_makeplot.delay(f1,f2,t,
# hrdata,plotnr,imagename) # hrpwrdata,plotnr,imagename)
if settings.DEBUG: if settings.DEBUG:
res = handle_makeplot.delay(f1,f2,t, res = handle_makeplot.delay(f1,f2,t,
hrdata,plotnr, hrpwrdata,plotnr,
imagename) imagename)
else: else:
res = queue.enqueue(handle_makeplot,f1,f2, res = queue.enqueue(handle_makeplot,f1,f2,
t,hrdata, t,hrpwrdata,
plotnr,imagename) plotnr,imagename)
@@ -3900,7 +3905,7 @@ def workout_summary_restore_view(request,id,message="",successmessage=""):
r = Rower.objects.get(user=u) r = Rower.objects.get(user=u)
rr = rrower(hrmax=r.max,hrut2=r.ut2, rr = rrower(hrmax=r.max,hrut2=r.ut2,
hrut1=r.ut1,hrat=r.at, hrut1=r.ut1,hrat=r.at,
hrtr=r.tr,hran=r.an) hrtr=r.tr,hran=r.an,ftp=r.ftp)
rowdata = rdata(f1,rower=rr) rowdata = rdata(f1,rower=rr)
if rowdata == 0: if rowdata == 0:
return HttpResponse("Error: CSV Data File Not Found") return HttpResponse("Error: CSV Data File Not Found")
@@ -3948,7 +3953,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
r = Rower.objects.get(user=u) r = Rower.objects.get(user=u)
rr = rrower(hrmax=r.max,hrut2=r.ut2, rr = rrower(hrmax=r.max,hrut2=r.ut2,
hrut1=r.ut1,hrat=r.at, hrut1=r.ut1,hrat=r.at,
hrtr=r.tr,hran=r.an) hrtr=r.tr,hran=r.an,ftp=r.ftp)
rowdata = rdata(f1,rower=rr) rowdata = rdata(f1,rower=rr)
if rowdata == 0: if rowdata == 0:
return HttpResponse("Error: CSV Data File Not Found") return HttpResponse("Error: CSV Data File Not Found")
@@ -4120,7 +4125,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
@login_required() @login_required()
def rower_edit_view(request,message=""): def rower_edit_view(request,message=""):
if request.method == 'POST': if request.method == 'POST' and "ut2" in request.POST:
form = RowerForm(request.POST) form = RowerForm(request.POST)
if form.is_valid(): if form.is_valid():
# something # something
@@ -4159,13 +4164,42 @@ def rower_edit_view(request,message=""):
# response = HttpResponseRedirect(url) # response = HttpResponseRedirect(url)
return response
elif request.method == 'POST' and "ftp" in request.POST:
form = RowerPowerForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
ftp = cd['ftp']
try:
r = Rower.objects.get(user=request.user)
r.ftp = max(min(ftp,650),50)
r.save()
message = "Functional Threshold Value Changed"
url = reverse(workouts_view,args=[str(message)])
response = HttpResponseRedirect(url)
except Rower.DoesNotExist:
message = "Funny. This user doesn't exist."
url = reverse(workouts_view,args=[str(message)])
response = HttpResponseRedirect(url)
else:
message = HttpResponse("invalid form")
return render(request, 'rower_form.html',
{'form':form,
'powerform':powerform,
})
return response return response
else: else:
try: try:
r = Rower.objects.get(user=request.user) r = Rower.objects.get(user=request.user)
form = RowerForm(instance=r) form = RowerForm(instance=r)
powerform = RowerPowerForm(instance=r)
return render(request, 'rower_form.html', return render(request, 'rower_form.html',
{'form':form,}) {
'form':form,
'powerform':powerform,
})
except Rower.DoesNotExist: except Rower.DoesNotExist:
return HttpResponse("This user doesn't exist") return HttpResponse("This user doesn't exist")