diff --git a/rowers/management/commands/processemail.py b/rowers/management/commands/processemail.py index 45d2a4f4..9f0f5c54 100644 --- a/rowers/management/commands/processemail.py +++ b/rowers/management/commands/processemail.py @@ -96,12 +96,24 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False): url = "http://localhost:8000/rowers/workout/api/upload/" - response = requests.post(url,data=uploadoptions) - if response.status_code == 200: - response_json = response.json() - workoutid = [int(response_json['id'])] - else: - workoutid = [0] + if not testing: + response = requests.post(url,data=uploadoptions) + if response.status_code == 200: + response_json = response.json() + workoutid = [int(response_json['id'])] + else: + workoutid = [0] + + # this is ugly and needs to be done better + if testing: + workoutid = [ + make_new_workout_from_email(therower, filename, title,testing=testing) + ] + if workoutid[0] and uploadoptions and not 'error' in uploadoptions: + workout = Workout.objects.get(id=workoutid[0]) + uploads.make_private(workout, uploadoptions) + uploads.set_workouttype(workout, uploadoptions) + uploads.do_sync(workout, uploadoptions) if 'raceid' in uploadoptions and workoutid[0] and rower.user.is_staff: