Private
Public Access
1
0

solved private, added raceid

This commit is contained in:
2025-10-22 08:44:55 +02:00
parent fd9c00dcfe
commit b6d8ec0429
3 changed files with 63 additions and 6 deletions

View File

@@ -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