diff --git a/rowers/management/commands/processemail.py b/rowers/management/commands/processemail.py index f4790e6e..95bc028c 100644 --- a/rowers/management/commands/processemail.py +++ b/rowers/management/commands/processemail.py @@ -84,13 +84,13 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False): make_new_workout_from_email(therower, filename, title,testing=testing) ] - if testing and workoutid[0]: - w = Workout.objects.get(id = workoutid[0]) - w.startdatetime = timezone.now() - w.date = timezone.now().date() - w.save() - if 'raceid' in uploadoptions and workoutid[0]: + if 'raceid' in uploadoptions and workoutid[0] and rower.user.is_staff: + if testing and workoutid[0]: + w = Workout.objects.get(id = workoutid[0]) + w.startdatetime = timezone.now() + w.date = timezone.now().date() + w.save() try: race = VirtualRace.objects.get(id=uploadoptions['raceid']) if race.manager == rower.user: diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py index bce4fe64..62aaeff9 100644 --- a/rowers/plannedsessions.py +++ b/rowers/plannedsessions.py @@ -36,6 +36,9 @@ import courses import iso8601 from iso8601 import ParseError from rowers.tasks import handle_check_race_course +from rowers.tasks import ( + handle_sendemail_raceregistration,handle_sendemail_racesubmission + ) from rowers.utils import totaltime_sec_to_string def get_indoorraces(workout): @@ -891,6 +894,7 @@ def email_submit_race(r,race,workoutid): w.duration = totaltime_sec_to_string(60.*race.sessionvalue) w.save() + elif race.sessionmode == 'distance': delta = w.distance - race.sessionvalue @@ -938,6 +942,7 @@ def email_submit_race(r,race,workoutid): otherrecords = IndoorVirtualRaceResult.objects.filter( race = race).exclude(userid = r.id) + for otherrecord in otherrecords: otheruser = Rower.objects.get(id=otherrecord.userid) othername = otheruser.user.first_name+' '+otheruser.user.last_name @@ -960,7 +965,6 @@ def email_submit_race(r,race,workoutid): ) if not records: - print 'jet' return 0 record = records[0] @@ -971,7 +975,7 @@ def email_submit_race(r,race,workoutid): workouts,race,r,recordid=record.id ) - + if result: otherrecords = IndoorVirtualRaceResult.objects.filter( race = race).exclude(userid = r.id) diff --git a/rowers/tests/testdata/testdata.csv.gz b/rowers/tests/testdata/testdata.csv.gz index a1e65d61..5201c511 100644 Binary files a/rowers/tests/testdata/testdata.csv.gz and b/rowers/tests/testdata/testdata.csv.gz differ diff --git a/rowers/tests/testdata/testdata.tcx b/rowers/tests/testdata/testdata.tcx index 858b5297..09a7a0bc 100644 --- a/rowers/tests/testdata/testdata.tcx +++ b/rowers/tests/testdata/testdata.tcx @@ -2502,7 +2502,7 @@ - <Element 'Notes' at 0x15bdb668> + <Element 'Notes' at 0x153817f0>