Private
Public Access
1
0

working submission

This commit is contained in:
Sander Roosendaal
2020-06-21 12:48:24 +02:00
parent 36f54783f7
commit ba0b351130
4 changed files with 86 additions and 32 deletions

View File

@@ -12,6 +12,8 @@ billiard==3.6.0.0
bleach==3.1.0 bleach==3.1.0
bokeh==1.0.4 bokeh==1.0.4
boto==2.49.0 boto==2.49.0
boto3==1.14.7
botocore==1.17.7
braintree==3.55.0 braintree==3.55.0
cairocffi==1.0.2 cairocffi==1.0.2
celery==4.3.0 celery==4.3.0
@@ -53,7 +55,7 @@ django-rest-framework==0.1.0
django-rest-swagger==2.2.0 django-rest-swagger==2.2.0
django-rq==1.3.1 django-rq==1.3.1
django-rq-dashboard==0.3.3 django-rq-dashboard==0.3.3
django-ses==0.8.10 django-ses==1.0.0
django-shell-plus==1.1.7 django-shell-plus==1.1.7
django-social-share==1.3.2 django-social-share==1.3.2
django-suit==0.2.26 django-suit==0.2.26
@@ -96,6 +98,7 @@ itypes==1.1.0
jedi==0.13.3 jedi==0.13.3
jeepney==0.4 jeepney==0.4
Jinja2==2.10 Jinja2==2.10
jmespath==0.10.0
json5==0.8.5 json5==0.8.5
jsonschema==3.0.1 jsonschema==3.0.1
jupyter==1.0.0 jupyter==1.0.0
@@ -125,7 +128,7 @@ newrelic==5.2.1.129
nose==1.3.7 nose==1.3.7
nose-parameterized==0.6.0 nose-parameterized==0.6.0
notebook==5.7.6 notebook==5.7.6
numba==0.46.0 numba==0.50.0
numpy==1.18.5 numpy==1.18.5
oauth2==1.9.0.post1 oauth2==1.9.0.post1
oauthlib==3.0.1 oauthlib==3.0.1
@@ -179,6 +182,7 @@ rowingdata==2.9.1
rowingphysics==0.5.0 rowingphysics==0.5.0
rq==0.13.0 rq==0.13.0
rules==2.1 rules==2.1
s3transfer==0.3.3
scipy==1.2.1 scipy==1.2.1
SecretStorage==3.1.1 SecretStorage==3.1.1
Send2Trash==1.5.0 Send2Trash==1.5.0

View File

@@ -386,7 +386,7 @@ class UploadOptionsForm(forms.Form):
makeprivate = forms.BooleanField(initial=False,required=False, makeprivate = forms.BooleanField(initial=False,required=False,
label='Make Workout Private') label='Make Workout Private')
submitrace = forms.ModelChoiceField(queryset=VirtualRace.objects.all(), submitrace = forms.ChoiceField(
label='Submit as challenge Result', label='Submit as challenge Result',
required=False) required=False)
@@ -404,6 +404,7 @@ class UploadOptionsForm(forms.Form):
r = Rower.objects.get(user=self.request.user) r = Rower.objects.get(user=self.request.user)
races = VirtualRace.objects.filter( races = VirtualRace.objects.filter(
registration_closure__gt=timezone.now()) registration_closure__gt=timezone.now())
registrations = IndoorVirtualRaceResult.objects.filter( registrations = IndoorVirtualRaceResult.objects.filter(
race__in = races, race__in = races,
userid = r.id) userid = r.id)
@@ -413,25 +414,27 @@ class UploadOptionsForm(forms.Form):
userid = r.id, userid = r.id,
) )
raceids = [r.race.id for r in registrations] choices1 = [(r.id,str(r)) for r in registrations]
raceids2 = [r.race.id for r in registrations2] choices2 = [(r.id,str(r)) for r in registrations2]
choices3 = [(0,'---')]
raceids = raceids+raceids2 choices = choices3+choices1+choices2
races = VirtualRace.objects.filter( if int(raceid) in [r.id for r in races]:
id__in=raceids therace = VirtualRace.objects.get(id=raceid)
) if therace.sessiontype == 'race':
registrations = VirtualRaceResult.objects.filter(race=therace,userid=r.id)
else:
registrations = IndoorVirtualRaceResult.objects.filter(race=therace,userid=r.id)
choices = [(r.id,str(r)) for r in registrations]
choices = [(0,'---')]+choices
if races: if races:
self.fields['submitrace'].queryset = races self.fields['submitrace'].choices = choices
else: else:
del self.fields['submitrace'] del self.fields['submitrace']
if int(raceid) in raceids:
self.fields['submitrace'].initial = VirtualRace.objects.get(id=raceid)
# The form to indicate additional actions to be performed immediately # The form to indicate additional actions to be performed immediately
# after a successful upload. This version allows the Team manager to select # after a successful upload. This version allows the Team manager to select

View File

@@ -1343,6 +1343,7 @@ def remove_rower_race(r,race,recordid=None):
# Low Level functions - to be called by higher level methods # Low Level functions - to be called by higher level methods
def add_workout_indoorrace(ws,race,r,recordid=0): def add_workout_indoorrace(ws,race,r,recordid=0):
print('aap')
result = 0 result = 0
comments = [] comments = []
errors = [] errors = []
@@ -1402,6 +1403,8 @@ def add_workout_indoorrace(ws,race,r,recordid=0):
workoutid = ws[0].id workoutid = ws[0].id
) )
print(record,records)
if not record: if not record:
errors.append("Couldn't find this entry") errors.append("Couldn't find this entry")
return result,comments,errors,0 return result,comments,errors,0
@@ -1471,7 +1474,7 @@ def add_workout_indoorrace(ws,race,r,recordid=0):
return result,comments,errors,0 return result,comments,errors,0
def add_workout_race(ws,race,r,splitsecond=0,recordid=0): def add_workout_race(ws,race,r,splitsecond=0,recordid=0,doregister=False):
result = 0 result = 0
comments = [] comments = []
errors = [] errors = []

View File

@@ -4909,7 +4909,7 @@ def workout_upload_view(request,
notes = form.cleaned_data['notes'] notes = form.cleaned_data['notes']
offline = form.cleaned_data['offline'] offline = form.cleaned_data['offline']
race = None registrationid = 0
if optionsform.is_valid(): if optionsform.is_valid():
make_plot = optionsform.cleaned_data['make_plot'] make_plot = optionsform.cleaned_data['make_plot']
plottype = optionsform.cleaned_data['plottype'] plottype = optionsform.cleaned_data['plottype']
@@ -4923,9 +4923,9 @@ def workout_upload_view(request,
landingpage = optionsform.cleaned_data['landingpage'] landingpage = optionsform.cleaned_data['landingpage']
try: try:
race = optionsform.cleaned_data['submitrace'] registrationid = optionsform.cleaned_data['submitrace']
except KeyError: except KeyError:
race = None registrationid = 0
uploadoptions = { uploadoptions = {
'makeprivate':makeprivate, 'makeprivate':makeprivate,
@@ -5113,17 +5113,60 @@ def workout_upload_view(request,
else: else:
messages.error(request,message) messages.error(request,message)
if race and race_can_submit(r,race): if int(registrationid) < 0:
if race.sessiontype == 'indoorrace': race = VirtualRace.Objects.get(id=-int(registrationid))
records = IndoorVirtualRaceResult.objects.filter( if race.sessiontype == 'race':
race=race, race = registrations[0].race
userid=r.id result,comments,errors,jobid = add_workout_race(
[w], race,r,
)
if result:
messages.info(
request,
"We have submitted your workout to the race")
for c in comments:
messages.info(request,c)
for er in errors:
messages.error(request,er)
elif race.sessiontype == 'indoorrace':
race = registrations[0].race
result,comments,errors,jobid = add_workout_indoorrace(
[w],race,r,
) )
if records: if result:
messages.info(
request,
"We have submitted your workout to the race")
for c in comments:
messages.info(request,c)
for er in errors:
messages.error(request,er)
if int(registrationid)>0:
races = VirtualRace.objects.filter(
registration_closure__gt=timezone.now()
)
registrations = IndoorVirtualRaceResult.objects.filter(
race__in = races,
id=registrationid,
userid = r.id,
)
registrations2 = VirtualRaceResult.objects.filter(
race__in = races,
id=registrationid,
userid=r.id,
)
if int(registrationid) in [r.id for r in registrations]:
# indoor race
registrations = registrations.filter(id=registrationid)
if registrations:
race = registrations[0].race
result,comments,errors,jobid = add_workout_indoorrace( result,comments,errors,jobid = add_workout_indoorrace(
[w],race,r,recordid=records[0].id [w],race,r,recordid=registrations[0].id
) )
if result: if result:
@@ -5135,15 +5178,15 @@ def workout_upload_view(request,
messages.info(request,c) messages.info(request,c)
for er in errors: for er in errors:
messages.error(request,er) messages.error(request,er)
if race.sessiontype == 'race':
records = VirtualRaceResult.objects.filter(
race=race,userid=r.id
)
if records: if int(registrationid) in [r.id for r in registrations2]:
# race
registrations = registrations2.filter(id=registrationid)
if registrations:
race = registrations[0].race
result,comments,errors,jobid = add_workout_race( result,comments,errors,jobid = add_workout_race(
[w], race,r,recordid=records[0].id [w], race,r,recordid=registrations[0].id
) )
if result: if result:
messages.info( messages.info(
@@ -5156,6 +5199,7 @@ def workout_upload_view(request,
messages.error(request,er) messages.error(request,er)
if landingpage != 'workout_upload_view': if landingpage != 'workout_upload_view':
url = reverse(landingpage, url = reverse(landingpage,
kwargs = { kwargs = {