Private
Public Access
1
0

Merge branch 'release/v16.1.2'

This commit is contained in:
Sander Roosendaal
2021-05-03 15:53:43 +02:00
5 changed files with 53 additions and 24 deletions

View File

@@ -3772,7 +3772,7 @@ def auto_delete_image_on_delete(sender,instance, **kwargs):
if others.count() == 0:
os.remove(instance.filename)
else:
print("couldn't find the file "+instance.filename)
pass

View File

@@ -162,8 +162,6 @@ class CPChartTest(TestCase):
sex = r.sex,
weightc = r.weightcategory)
print(url)
response = self.c.get(url)
self.assertEqual(response.status_code,200)

View File

@@ -1931,6 +1931,25 @@ description: ""
self.assertEqual(self.ps_trimp.approximate_rscore,72)
@patch('rowers.garmin_stuff.requests.post', side_effect=mocked_requests)
@patch('rowers.utils.requests.post', side_effect=mocked_requests)
@patch('rowers.garmin_stuff.OAuth1Session', side_effect=MockOAuth1Session)
def test_plannedsession_steps_distance(self,mockpost,mock_post,MockOAuth1Session):
self.ps_trimp.interval_string = '10km'
self.ps_trimp.save()
self.assertEqual(self.ps_trimp.approximate_rscore,52)
@patch('rowers.garmin_stuff.requests.post', side_effect=mocked_requests)
@patch('rowers.utils.requests.post', side_effect=mocked_requests)
@patch('rowers.garmin_stuff.OAuth1Session', side_effect=MockOAuth1Session)
def test_plannedsession_steps_time(self,mockpost,mock_post,MockOAuth1Session):
self.ps_trimp.interval_string = '60min'
self.ps_trimp.save()
self.assertEqual(self.ps_trimp.approximate_rscore,60)
def test_plannedsessions_dateform_view(self):
login = self.c.login(username=self.u.username, password=self.password)
self.assertTrue(login)

View File

@@ -599,20 +599,18 @@ def step_to_time_dist(step,avgspeed = 3.2,ftp=200,ftspm=25,ftv=3.7):
except KeyError: # pragma: no cover
targettype = 0
if durationtype == 'Time':
value = step['durationValue']
seconds = value/1000.
distance = avgspeed*seconds
rscore = 60.*seconds/3600.
if targettype == 'Speed':
value = step.get('targetValue',0)
valuelow = step.get('targetValueLow',0)
valuehigh = step.get('targetValueHigh',0)
velomid = 0.
if value != 0:
if value != 0: # pragma: no cover
distance = seconds*value/1000.
velomid = value/1000.
elif valuelow != 0 and valuehigh != 0: # pragma: no cover
@@ -663,6 +661,7 @@ def step_to_time_dist(step,avgspeed = 3.2,ftp=200,ftspm=25,ftv=3.7):
value = step['durationValue']
distance = value/100.
seconds = distance/avgspeed
rscore = 60*seconds/3600.
if targettype == 'Speed':
value = step.get('targetValue',0)
@@ -779,13 +778,19 @@ def ps_dict_order_dict(d,short=False):
return sdict2
def ps_dict_order(d,short=False):
def ps_dict_order(d,short=False,rower=None):
sdict = collections.OrderedDict({})
steps = d['steps']
ftp = 200
if rower is not None:
ftp = rower.ftp
# ftv = rower.ftv
# ftspm = rower.ftspm
for step in steps:
sstring, type, stepID, repeatID, repeatValue = step_to_string(step,short=short)
seconds, meters,rscore = step_to_time_dist(step)
seconds, meters,rscore = step_to_time_dist(step,ftp=ftp)
sdict[stepID] = {
'string':sstring,

View File

@@ -1477,22 +1477,29 @@ def plannedsessions_view(request,
sessioncolor[ps.id] = cratiocolors[status]
ws = Workout.objects.filter(user=r,plannedsession=ps)
completiondate[ps.id] = cdate
if ps.sessionmode == 'distance':
totals['planneddistance'] += ps.sessionvalue
if ps.steps:
sdict, totalmeters, totalseconds, totalrscore = ps_dict_order(ps.steps,rower=r)
totals['planneddistance'] += int(totalmeters)
totals['plannedtime'] += int(totalseconds)/60.
totals['plannedrscore'] += int(totalrscore)
totals['plannedtrimp'] += int(totalrscore)*2
else:
totals['planneddistance'] += ps.approximate_distance
if ps.sessionmode == 'time':
totals['plannedtime'] += ps.sessionvalue
else:
totals['plannedtime'] += ps.approximate_duration
if ps.sessionmode == 'rScore': # pragma: no cover
totals['plannedrscore'] += ps.sessionvalue
else:
totals['plannedrscore'] += ps.approximate_rscore
if ps.sessionmode == 'TRIMP': # pragma: no cover
totals['plannedtrimp'] += ps.sessionvalue
else:
totals['plannedtrimp'] += ps.approximate_rscore*2
if ps.sessionmode == 'distance':
totals['planneddistance'] += ps.sessionvalue
else:
totals['planneddistance'] += ps.approximate_distance
if ps.sessionmode == 'time':
totals['plannedtime'] += ps.sessionvalue
else:
totals['plannedtime'] += ps.approximate_duration
if ps.sessionmode == 'rScore': # pragma: no cover
totals['plannedrscore'] += ps.sessionvalue
else:
totals['plannedrscore'] += ps.approximate_rscore
if ps.sessionmode == 'TRIMP': # pragma: no cover
totals['plannedtrimp'] += ps.sessionvalue
else:
totals['plannedtrimp'] += ps.approximate_rscore*2
totals['time'] = int(totals['time']/60.)
totals['actualtime'] = int(totals['actualtime']/60.)