diff --git a/rowers/models.py b/rowers/models.py index 8db34f4e..94055201 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -2422,7 +2422,15 @@ class PlannedSession(models.Model): steps = self.steps - steps['filename'] = settings.MEDIA_ROOT+'/'+filename + try: + steps['filename'] = settings.MEDIA_ROOT+'/'+filename + except TypeError: + try: + steps['filename'] = filename.name + except TypeError: + steps = json.loads(steps) + steps['filename'] = filename.name + self.steps = steps fitfile = steps_write_fit(steps) filelist = fitfile.split('/media/') diff --git a/rowers/templates/developers.html b/rowers/templates/developers.html index cb718b16..2732b6ec 100644 --- a/rowers/templates/developers.html +++ b/rowers/templates/developers.html @@ -216,23 +216,22 @@
{
- "id": 17,
- "name": "Test Session",
- "comment": "",
- "startdate": "2021-01-25",
- "enddate": "2021-01-31",
- "preferreddate": "2021-01-29",
- "sessiontype": "session",
- "sessionvalue": 60,
- "sessionunit": "min",
- "sessionmode": "time",
- "manager": 1,
- "course": null,
- "approximate_distance": 10000,
- "approximate_duration": 60,
- "steps_json": "{\"filename\": \"/home/sander/python/rowsandall/media/8663f42528-20210213-133008-2021-02-16_4x500m2min_gMmFiFR.fit\", \"name\": \"4x500m/2min\", \"steps\": [{\"wkt_step_name\": \"Warm up\", \"duration_distance\": 2000.0, \"target_type\": \"heart_rate\", \"target_hr_zone\": 0, \"custom_target_heart_rate_low\": 183, \"custom_target_heart_rate_high\": 188, \"intensity\": \"warmup\", \"message_index\": 0, \"duration_type\": \"distance\"}, {\"wkt_step_name\": \"Active\", \"duration_distance\": 500.0, \"target_type\": \"heart_rate\", \"target_hr_zone\": 0, \"custom_target_heart_rate_low\": 239, \"custom_target_heart_rate_high\": 246, \"intensity\": \"active\", \"message_index\": 1, \"duration_type\": \"distance\"}, {\"wkt_step_name\": \"Recovery\", \"duration_time\": 120.0, \"target_type\": \"heart_rate\", \"target_hr_zone\": 0, \"custom_target_heart_rate_low\": 202, \"custom_target_heart_rate_high\": 207, \"intensity\": \"rest\", \"message_index\": 2, \"duration_type\": \"time\"}, {\"wkt_step_name\": \"Active\", \"duration_distance\": 500.0, \"target_type\": \"heart_rate\", \"target_hr_zone\": 0, \"custom_target_heart_rate_low\": 239, \"custom_target_heart_rate_high\": 246, \"intensity\": \"active\", \"message_index\": 3, \"duration_type\": \"distance\"}, {\"wkt_step_name\": \"Recovery\", \"duration_time\": 120.0, \"target_type\": \"heart_rate\", \"target_hr_zone\": 0, \"custom_target_heart_rate_low\": 202, \"custom_target_heart_rate_high\": 207, \"intensity\": \"rest\", \"message_index\": 4, \"duration_type\": \"time\"}, {\"wkt_step_name\": \"Active\", \"duration_distance\": 500.0, \"target_type\": \"heart_rate\", \"target_hr_zone\": 0, \"custom_target_heart_rate_low\": 239, \"custom_target_heart_rate_high\": 246, \"intensity\": \"active\", \"message_index\": 5, \"duration_type\": \"distance\"}, {\"wkt_step_name\": \"Recovery\", \"duration_time\": 120.0, \"target_type\": \"heart_rate\", \"target_hr_zone\": 0, \"custom_target_heart_rate_low\": 202, \"custom_target_heart_rate_high\": 207, \"intensity\": \"rest\", \"message_index\": 6, \"duration_type\": \"time\"}, {\"wkt_step_name\": \"Active\", \"duration_distance\": 500.0, \"target_type\": \"heart_rate\", \"target_hr_zone\": 0, \"custom_target_heart_rate_low\": 239, \"custom_target_heart_rate_high\": 246, \"intensity\": \"active\", \"message_index\": 7, \"duration_type\": \"distance\"}, {\"wkt_step_name\": \"Recovery\", \"duration_time\": 120.0, \"target_type\": \"heart_rate\", \"target_hr_zone\": 0, \"custom_target_heart_rate_low\": 202, \"custom_target_heart_rate_high\": 207, \"intensity\": \"rest\", \"message_index\": 8, \"duration_type\": \"time\"}, {\"wkt_step_name\": \"Cool Down\", \"duration_distance\": 2000.0, \"target_type\": \"heart_rate\", \"target_hr_zone\": 0, \"custom_target_heart_rate_low\": 183, \"custom_target_heart_rate_high\": 188, \"intensity\": \"cooldown\", \"message_index\": 9, \"duration_type\": \"distance\"}, {\"wkt_step_name\": null, \"duration_value\": null, \"target_type\": null, \"target_value\": null, \"custom_target_value_low\": null, \"custom_target_value_high\": null, \"intensity\": \"cooldown\", \"message_index\": 10, \"duration_type\": \"open\"}], \"sport\": \"rowing\"}",
- "fitfile": "https://rowsandall.com/media/8663f42528-20210213-133008-2021-02-16_4x500m2min_gMmFiFR.fit"
- }
+ "id": 103,
+ "name": "ExampleSession",
+ "comment": "",
+ "startdate": "2021-03-01",
+ "enddate": "2021-03-06",
+ "preferreddate": "2021-03-01",
+ "sessiontype": "session",
+ "sessionvalue": 74,
+ "sessionunit": "min",
+ "sessionmode": "time",
+ "course": null,
+ "approximate_distance": 16440,
+ "approximate_duration": 74,
+ "steps": "{'filename': 'media/a7a7a621ad-20210302-074033-tmp2zcd7i_0.fit', 'workoutName': '', 'steps': [{'stepId': 0, 'wkt_step_name': '0', 'durationType': 'Distance', 'durationValue': 200000, 'targetType': 'Speed', 'targetValue': 0, 'targetValueLow': 0, 'targetValueHigh': 0, 'intensity': 'Rest', 'description': ''}, {'stepId': 1, 'wkt_step_name': '1', 'durationType': 'Distance', 'durationValue': 200000, 'targetType': 'Speed', 'targetValue': 0, 'targetValueLow': 0, 'targetValueHigh': 0, 'intensity': 'Active', 'description': ''}, {'stepId': 2, 'wkt_step_name': '2', 'durationType': 'Time', 'durationValue': 300000, 'targetType': 'Speed', 'targetValue': 0, 'targetValueLow': 0, 'targetValueHigh': 0, 'intensity': 'Rest', 'description': ''}, {'stepId': 3, 'wkt_step_name': '3', 'durationType': 'Distance', 'durationValue': 200000, 'targetType': 'Speed', 'targetValue': 0, 'targetValueLow': 0, 'targetValueHigh': 0, 'intensity': 'Active', 'description': ''}, {'stepId': 4, 'wkt_step_name': '4', 'durationType': 'Time', 'durationValue': 300000, 'targetType': 'Speed', 'targetValue': 0, 'targetValueLow': 0, 'targetValueHigh': 0, 'intensity': 'Rest', 'description': ''}, {'stepId': 5, 'wkt_step_name': '5', 'durationType': 'Distance', 'durationValue': 200000, 'targetType': 'Speed', 'targetValue': 0, 'targetValueLow': 0, 'targetValueHigh': 0, 'intensity': 'Active', 'description': ''}, {'stepId': 6, 'wkt_step_name': '6', 'durationType': 'Time', 'durationValue': 300000, 'targetType': 'Speed', 'targetValue': 0, 'targetValueLow': 0, 'targetValueHigh': 0, 'intensity': 'Rest', 'description': ''}, {'stepId': 7, 'wkt_step_name': '7', 'durationType': 'Distance', 'durationValue': 200000, 'targetType': 'Speed', 'targetValue': 0, 'targetValueLow': 0, 'targetValueHigh': 0, 'intensity': 'Active', 'description': ''}, {'stepId': 8, 'wkt_step_name': '8', 'durationType': 'Time', 'durationValue': 300000, 'targetType': 'Speed', 'targetValue': 0, 'targetValueLow': 0, 'targetValueHigh': 0, 'intensity': 'Rest', 'description': ''}, {'stepId': 9, 'wkt_step_name': '9', 'durationType': 'Distance', 'durationValue': 200000, 'targetType': 'Speed', 'targetValue': 0, 'targetValueLow': 0, 'targetValueHigh': 0, 'intensity': 'Rest', 'description': ''}], 'sport': '', 'description': ''}",
+ "fitfile": "https://rowsandall.com/media/a7a7a621ad-20210302-074033-tmp2zcd7i_0.fit"
+}