Private
Public Access
1
0

fixing steps dictionary

This commit is contained in:
Sander Roosendaal
2021-03-05 15:42:58 +01:00
parent 9e459b1bb3
commit 7e09d08074

View File

@@ -2367,6 +2367,14 @@ class PlannedSession(models.Model):
dct = trainingparser.parsetodict(self.interval_string)
dct = [item for item in dct if item['value'] != 0]
dct = trainingparser.tofitdict(dct)
for step in dct['steps']:
try:
step['targetValue'] = int(step['targetValue'])
step['targetValueLow'] = int(step['targetValueHigh'])
step['targetValueHigh'] = int(step['targetValueLow'])
except KeyError:
pass
self.steps = dct
# sort units
@@ -2413,12 +2421,13 @@ class PlannedSession(models.Model):
if self.steps and not self.fitfile:
filename = 'aap.fit'
filename = get_file_path(self,filename)
steps = self.steps
steps['filename'] = os.path.join(settings.MEDIA_ROOT,filename)
fitfile = steps_write_fit(steps)
self.fitfile.name = filename
self.steps = steps
print(self.fitfile.name,filename)
# calculate approximate distance
if self.steps: