diff --git a/rowers/dataflow.py b/rowers/dataflow.py index 92d3500b..c938a84a 100644 --- a/rowers/dataflow.py +++ b/rowers/dataflow.py @@ -42,7 +42,7 @@ from rowingdata import rower as rrower from rowers.dataroutines import rdata, get_startdate_time_zone, df_resample, checkduplicates, dataplep from rowers.mytypes import otetypes, otwtypes from rowers.utils import totaltime_sec_to_string -from rowers.dataprep import check_marker, checkbreakthrough, update_wps +from rowers.dataprep import check_marker, checkbreakthrough, update_wps, handle_nonpainsled from rowers.emails import send_confirm from rowers.tasks import handle_sendemail_unrecognized, handle_sendemail_breakthrough, handle_sendemail_hard, handle_calctrimp @@ -117,7 +117,7 @@ def is_invalid_file(file_path): extension = extension2 f4 = filename+'a'+extension copyfile(f2, f4) - _ = myqueue(queuehigh, + _ = myqueue(queuelow, handle_sendemail_unrecognized, f4, r.user.email) @@ -299,11 +299,13 @@ def update_workout_attributes(w, row, file_path, uploadoptions, boatname = uploadoptions.get('boatName','') portStarboard = uploadoptions.get('portStarboard', 1) empowerside = 'port' + raceid = uploadoptions.get('raceid', 0) + registrationid = uploadoptions.get('submitrace', 0) if portStarboard == 1: empowerside = 'starboard' - stravaid = uploadoptions.get('stravaid','') + stravaid = uploadoptions.get('stravaid',0) if stravaid != 0: workoutsource = 'strava' @@ -408,7 +410,50 @@ def update_workout_attributes(w, row, file_path, uploadoptions, w.privacy = privacy w.impeller = useImpeller w.save() - + + # check for registrationid + if registrationid != 0: + races = VirtualRace.objects.filter( + registration_closure__gt=tz.now(), + id=raceid, + ) + registrations = IndoorVirtualRaceResult.objects.filter( + race__in=races, + id=registrationid, + userid=w.user.id + ) + registrations2 = VirtualRaceResult.objects.filter( + race__in=races, + id=registrationid, + userid=w.user.id) + + if registrationid in [r.id for r in registrations]: + # indoor race + registrations = registrations.filter(id=registrationid) + if registrations: + race = registrations[0].race + if race.sessiontype == 'indoorrace': + result, comments, errors, jobid = add_workout_indoorrace( + [w], race, w.user, recordid=registrations[0].id + ) + elif race.sessiontype in ['fastest_time', 'fastest_distance']: + result, comments, errors, jobid = add_workout_fastestrace( + [w], race, w.user, recordid=registrations[0].id + ) + + if registrationid in [r.id for r in registrations2]: + registration = registrations2.filter(id=registrationid) + if registrations: + race = registrations[0].race + if race.sessiontype == 'race': + result, comments, errors, jobid = add_workout_race( + [w], race, w.user, recordid=registrations2[0].id + ) + elif race.sessiontype in ['fastest_time', 'fastest_distance']: + result, comments, errors, jobid = add_workout_fastestrace( + [w], race, w.user, recordid=registrations2[0].id + ) + return w def send_upload_confirmation_email(rower, workout): @@ -624,6 +669,7 @@ def process_single_file(file_path, uploadoptions, job_id, debug=False, **kwargs) # make plots if uploadoptions['make_plot']: + plottype = uploadoptions.get('plottype', 'timeplot') res, jobid = uploads.make_plot(r, w, f1, f2, plottype, w.name) elif r.staticchartonupload != 'None': # pragma: no cover plottype = r.staticchartonupload diff --git a/rowers/uploads.py b/rowers/uploads.py index 06273c63..01c7a213 100644 --- a/rowers/uploads.py +++ b/rowers/uploads.py @@ -104,7 +104,7 @@ def make_plot(r, w, f1, f2, plottype, title, imagename='', plotnr=0): otwrange = [r.fastpaceotw.total_seconds(), r.slowpaceotw.total_seconds()] oterange = [r.fastpaceerg.total_seconds(), r.slowpaceerg.total_seconds()] - job = myqueue(queuehigh, handle_makeplot, f1, f2, + job = myqueue(queue, handle_makeplot, f1, f2, title, hrpwrdata, plotnr, imagename, gridtrue=gridtrue, axis=axis, otwrange=otwrange, oterange=oterange) diff --git a/rowers/views/workoutviews.py b/rowers/views/workoutviews.py index fce5510e..609abe23 100644 --- a/rowers/views/workoutviews.py +++ b/rowers/views/workoutviews.py @@ -5283,6 +5283,15 @@ def workout_upload_view(request, } ] + if 'uploadoptions' in request.session: + uploadoptions = request.session['uploadoptions'] + try: + _ = uploadoptions['landingpage'] + except KeyError: # pragma: no cover + uploadoptions['landingpage'] = r.defaultlandingpage + else: + request.session['uploadoptions'] = uploadoptions + form = DocumentsForm(initial=uploadoptions) optionsform = UploadOptionsForm(initial=uploadoptions, request=request, raceid=raceid) @@ -5295,6 +5304,7 @@ def workout_upload_view(request, if form.is_valid() and optionsform.is_valid(): uploadoptions = form.cleaned_data.copy() uploadoptions.update(optionsform.cleaned_data) + request.session['uploadoptions'] = uploadoptions uploadoptions['secret'] = settings.UPLOAD_SERVICE_SECRET uploadoptions['user'] = r.user.id @@ -5493,7 +5503,8 @@ def team_workout_upload_view(request, userid=0, message="", return response else: form = DocumentsForm() - optionsform = TeamUploadOptionsForm(initial=uploadoptions) + optionsform = TeamUploadOptionsForm(initial=uploadoptions, + request=request,raceid=raceid) rowerform = TeamInviteForm(userid=userid) rowerform.fields.pop('email')