solved private, added raceid
This commit is contained in:
@@ -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.dataroutines import rdata, get_startdate_time_zone, df_resample, checkduplicates, dataplep
|
||||||
from rowers.mytypes import otetypes, otwtypes
|
from rowers.mytypes import otetypes, otwtypes
|
||||||
from rowers.utils import totaltime_sec_to_string
|
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.emails import send_confirm
|
||||||
from rowers.tasks import handle_sendemail_unrecognized, handle_sendemail_breakthrough, handle_sendemail_hard, handle_calctrimp
|
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
|
extension = extension2
|
||||||
f4 = filename+'a'+extension
|
f4 = filename+'a'+extension
|
||||||
copyfile(f2, f4)
|
copyfile(f2, f4)
|
||||||
_ = myqueue(queuehigh,
|
_ = myqueue(queuelow,
|
||||||
handle_sendemail_unrecognized,
|
handle_sendemail_unrecognized,
|
||||||
f4,
|
f4,
|
||||||
r.user.email)
|
r.user.email)
|
||||||
@@ -299,11 +299,13 @@ def update_workout_attributes(w, row, file_path, uploadoptions,
|
|||||||
boatname = uploadoptions.get('boatName','')
|
boatname = uploadoptions.get('boatName','')
|
||||||
portStarboard = uploadoptions.get('portStarboard', 1)
|
portStarboard = uploadoptions.get('portStarboard', 1)
|
||||||
empowerside = 'port'
|
empowerside = 'port'
|
||||||
|
raceid = uploadoptions.get('raceid', 0)
|
||||||
|
registrationid = uploadoptions.get('submitrace', 0)
|
||||||
|
|
||||||
if portStarboard == 1:
|
if portStarboard == 1:
|
||||||
empowerside = 'starboard'
|
empowerside = 'starboard'
|
||||||
|
|
||||||
stravaid = uploadoptions.get('stravaid','')
|
stravaid = uploadoptions.get('stravaid',0)
|
||||||
if stravaid != 0:
|
if stravaid != 0:
|
||||||
workoutsource = 'strava'
|
workoutsource = 'strava'
|
||||||
|
|
||||||
@@ -408,7 +410,50 @@ def update_workout_attributes(w, row, file_path, uploadoptions,
|
|||||||
w.privacy = privacy
|
w.privacy = privacy
|
||||||
w.impeller = useImpeller
|
w.impeller = useImpeller
|
||||||
w.save()
|
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
|
return w
|
||||||
|
|
||||||
def send_upload_confirmation_email(rower, workout):
|
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
|
# make plots
|
||||||
if uploadoptions['make_plot']:
|
if uploadoptions['make_plot']:
|
||||||
|
plottype = uploadoptions.get('plottype', 'timeplot')
|
||||||
res, jobid = uploads.make_plot(r, w, f1, f2, plottype, w.name)
|
res, jobid = uploads.make_plot(r, w, f1, f2, plottype, w.name)
|
||||||
elif r.staticchartonupload != 'None': # pragma: no cover
|
elif r.staticchartonupload != 'None': # pragma: no cover
|
||||||
plottype = r.staticchartonupload
|
plottype = r.staticchartonupload
|
||||||
|
|||||||
@@ -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()]
|
otwrange = [r.fastpaceotw.total_seconds(), r.slowpaceotw.total_seconds()]
|
||||||
oterange = [r.fastpaceerg.total_seconds(), r.slowpaceerg.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,
|
title, hrpwrdata,
|
||||||
plotnr, imagename, gridtrue=gridtrue, axis=axis,
|
plotnr, imagename, gridtrue=gridtrue, axis=axis,
|
||||||
otwrange=otwrange, oterange=oterange)
|
otwrange=otwrange, oterange=oterange)
|
||||||
|
|||||||
@@ -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)
|
form = DocumentsForm(initial=uploadoptions)
|
||||||
optionsform = UploadOptionsForm(initial=uploadoptions,
|
optionsform = UploadOptionsForm(initial=uploadoptions,
|
||||||
request=request, raceid=raceid)
|
request=request, raceid=raceid)
|
||||||
@@ -5295,6 +5304,7 @@ def workout_upload_view(request,
|
|||||||
if form.is_valid() and optionsform.is_valid():
|
if form.is_valid() and optionsform.is_valid():
|
||||||
uploadoptions = form.cleaned_data.copy()
|
uploadoptions = form.cleaned_data.copy()
|
||||||
uploadoptions.update(optionsform.cleaned_data)
|
uploadoptions.update(optionsform.cleaned_data)
|
||||||
|
request.session['uploadoptions'] = uploadoptions
|
||||||
|
|
||||||
uploadoptions['secret'] = settings.UPLOAD_SERVICE_SECRET
|
uploadoptions['secret'] = settings.UPLOAD_SERVICE_SECRET
|
||||||
uploadoptions['user'] = r.user.id
|
uploadoptions['user'] = r.user.id
|
||||||
@@ -5493,7 +5503,8 @@ def team_workout_upload_view(request, userid=0, message="",
|
|||||||
return response
|
return response
|
||||||
else:
|
else:
|
||||||
form = DocumentsForm()
|
form = DocumentsForm()
|
||||||
optionsform = TeamUploadOptionsForm(initial=uploadoptions)
|
optionsform = TeamUploadOptionsForm(initial=uploadoptions,
|
||||||
|
request=request,raceid=raceid)
|
||||||
rowerform = TeamInviteForm(userid=userid)
|
rowerform = TeamInviteForm(userid=userid)
|
||||||
rowerform.fields.pop('email')
|
rowerform.fields.pop('email')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user