Date: Sun, 21 Jun 2020 16:27:41 +0200
Subject: [PATCH 13/18] seems to be complete now
---
rowers/forms.py | 8 ++-
rowers/plannedsessions.py | 81 +++++++++++++++++++++++-------
rowers/templates/virtualevent.html | 3 ++
rowers/views/racesviews.py | 24 +++++++++
rowers/views/workoutviews.py | 16 +++---
5 files changed, 106 insertions(+), 26 deletions(-)
diff --git a/rowers/forms.py b/rowers/forms.py
index 694962b5..d3b23329 100644
--- a/rowers/forms.py
+++ b/rowers/forms.py
@@ -437,8 +437,12 @@ class UploadOptionsForm(forms.Form):
else:
registrations = IndoorVirtualRaceResult.objects.filter(race=therace,userid=r.id)
- choices = [(r.id,str(r)) for r in registrations]
- choices = [(0,'---')]+choices
+ if registrations.count()==0:
+ race = VirtualRace.objects.get(id=raceid)
+ choices = [(-int(raceid),race.name)]
+ else:
+ choices = [(r.id,str(r)) for r in registrations]
+ choices = choices+[(0,'---')]
if races:
self.fields['submitrace'].choices = choices
diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py
index 93206cbe..92166a78 100644
--- a/rowers/plannedsessions.py
+++ b/rowers/plannedsessions.py
@@ -1041,8 +1041,8 @@ def race_can_edit(r,race):
return False
def race_can_submit(r,race):
- if r not in race.rower.all():
- return False
+ #if r not in race.rower.all():
+ # return False
start_time = race.start_time
start_date = race.startdate
@@ -1451,12 +1451,34 @@ def add_workout_indoorrace(ws,race,r,recordid=0,doregister=False):
else:
age = None
- record = IndoorVirtualRaceResult.objects.get(
- userid=r.id,
- race=race,
- id=recordid
- )
-
+ try:
+ record = IndoorVirtualRaceResult.objects.get(
+ userid=r.id,
+ race=race,
+ id=recordid
+ )
+ except IndoorVirtualRaceResult.DoesNotExist:
+ if doregister:
+ hasinitial,boattype,boatclass,adaptiveclass,weightclass,sex,initialcategory = default_class(r,ws[0],race)
+ if hasinitial:
+ record = IndoorVirtualRaceResult(
+ userid = r.id,
+ username = r.user.first_name+' '+r.user.last_name,
+ weightcategory=weightclass,
+ adaptiveclass=adaptiveclass,
+ race=race,
+ boatclass=boatclass,
+ sex=sex,
+ age = age,
+ entrycategory=initialcategory,
+ )
+ record.save()
+ else:
+ errors.append("Unable to find a suitable start category")
+ return result,comments,errors,0
+ else:
+ errors.append("Couldn't find this entry")
+ return result,comments,errors,0
records = IndoorVirtualRaceResult.objects.filter(
userid=r.id,
@@ -1466,11 +1488,8 @@ def add_workout_indoorrace(ws,race,r,recordid=0,doregister=False):
- if not record and not doregister:
- errors.append("Couldn't find this entry")
- return result,comments,errors,0
- elif not record:
- pass
+
+
if race.sessionmode == 'distance':
@@ -1584,11 +1603,35 @@ def add_workout_race(ws,race,r,splitsecond=0,recordid=0,doregister=False):
else:
age = None
- record = VirtualRaceResult.objects.get(
- userid=r.id,
- race=race,
- id=recordid
- )
+ try:
+ record = VirtualRaceResult.objects.get(
+ userid=r.id,
+ race=race,
+ id=recordid
+ )
+ except VirtualRaceResult.DoesNotExist:
+ if doregister:
+ hasinitial,boattype,boatclass,adaptiveclass,weightclass,sex,initialcategory = default_class(r,ws[0],race)
+ if hasinitial:
+ record = VirtualRaceResult(
+ userid = r.id,
+ username = r.user.first_name+' '+r.user.last_name,
+ weightcategory=weightclass,
+ adaptiveclass=adaptiveclass,
+ race=race,
+ boatclass=boatclass,
+ boattype=boattype,
+ sex=sex,
+ age = age,
+ entrycategory=initialcategory,
+ )
+ record.save()
+ else:
+ errors.append("Unable to find a suitable start category")
+ return result,comments,errors,0
+ else:
+ errors.append("Couldn't find this entry")
+ return result,comments,errors,0
records = VirtualRaceResult.objects.filter(
userid=r.id,
@@ -1656,6 +1699,8 @@ def add_workout_race(ws,race,r,splitsecond=0,recordid=0,doregister=False):
referencespeed=record.referencespeed,coursedistance=race.course.distance
)
+ comments.append('We are now checking adherence to the race course. This may take a few minutes to complete')
+
add_workouts_plannedsession(ws,race,r)
diff --git a/rowers/templates/virtualevent.html b/rowers/templates/virtualevent.html
index 26d16084..6decfc0c 100644
--- a/rowers/templates/virtualevent.html
+++ b/rowers/templates/virtualevent.html
@@ -163,6 +163,7 @@
Registered users of rowsandall.com can participate in this challenge.
Participation is free, unless specified differently in the race comment above.
{% if race.sessiontype == 'race' %}
+ Register to let others know you plan to do this challenge:
Register
{% else %}
Register
@@ -183,6 +184,8 @@
{% for button in buttons %}
{% if button == 'registerbutton' %}
+ Register to let others know you plan to do this challenge. This also give you the option to
+ select your entry category:
{% if race.sessiontype == 'race' %}
Register
{% else %}
diff --git a/rowers/views/racesviews.py b/rowers/views/racesviews.py
index c2148ac0..93df6047 100644
--- a/rowers/views/racesviews.py
+++ b/rowers/views/racesviews.py
@@ -746,6 +746,7 @@ def virtualevent_disqualify_view(request,id=0,recordid=0):
r = getrower(request.user)
race = get_object_or_404(VirtualRace,pk=id)
+ raceid = race.id
if race.sessiontype == 'race':
@@ -2810,6 +2811,29 @@ def virtualevent_submit_result_view(request,id=0,workoutid=0):
race=race
)
+ if records.count() == 0:
+ hasinitial,boattype,boatclass,adaptiveclass,weightclass,sex,initialcategory = default_class(r,None,race)
+ if not hasinitial:
+ messages.error(request,"Sorry, you have to register first")
+ url = reverse('virtualevent_view',
+ kwargs = {
+ 'id':id,
+ })
+ return HttpResponseRedirect(url)
+ record = resultobj(
+ userid = r.id,
+ username = r.user.first_name+' '+r.user.last_name,
+ weightcategory=weightclass,
+ adaptiveclass=adaptiveclass,
+ race=race,
+ boatclass=boatclass,
+ sex=sex,
+ age=calculate_age(r.birthdate),
+ entrycategory=initialcategory,
+ )
+ record.save()
+ records = [record]
+
entrychoices = []
diff --git a/rowers/views/workoutviews.py b/rowers/views/workoutviews.py
index 79b8f1ea..914064b0 100644
--- a/rowers/views/workoutviews.py
+++ b/rowers/views/workoutviews.py
@@ -5114,11 +5114,10 @@ def workout_upload_view(request,
messages.error(request,message)
if int(registrationid) < 0:
- race = VirtualRace.Objects.get(id=-int(registrationid))
+ race = VirtualRace.objects.get(id=-int(registrationid))
if race.sessiontype == 'race':
- race = registrations[0].race
result,comments,errors,jobid = add_workout_race(
- [w], race,r,
+ [w], race,r,doregister=True,
)
if result:
messages.info(
@@ -5130,9 +5129,8 @@ def workout_upload_view(request,
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,
+ [w],race,r,doregister=True,
)
if result:
@@ -5200,11 +5198,17 @@ def workout_upload_view(request,
- if landingpage != 'workout_upload_view':
+ if registrationid != 0:
+ url = reverse('virtualevent_view',
+ kwargs = {
+ 'id':race.id,
+ })
+ elif landingpage != 'workout_upload_view':
url = reverse(landingpage,
kwargs = {
'id':encoder.encode_hex(w.id),
})
+
else:
url = reverse(landingpage)
From 14bc64b3db26c8c3cc3bae1a3c839b2df6c9d875 Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Sun, 21 Jun 2020 18:05:04 +0200
Subject: [PATCH 14/18] fix gender bug
---
rowers/plannedsessions.py | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py
index 92166a78..de3698ac 100644
--- a/rowers/plannedsessions.py
+++ b/rowers/plannedsessions.py
@@ -1372,8 +1372,9 @@ def default_class(r,w,race):
boatclass=boatclass,
adaptiveclass=adaptiveclass,
boattype=boattype,
- weightclass=weightclass
- ).order_by("agemax","-agemin","boattype")
+ weightclass=weightclass,
+ sex=sex,
+ ).order_by("agemax","-agemin","boattype","sex")
if standards.count()==0:
@@ -1382,12 +1383,12 @@ def default_class(r,w,race):
boatclass=boatclass,
adaptiveclass=adaptiveclass,
boattype=boattype,
- )
+ ).order_by("agemax","-agemin","boattype","sex")
if standards.count()==0:
standards = CourseStandard.objects.filter(agemin__lt=age,agemax__gt=age,
- boattype=boattype)
+ boattype=boattype).order_by("agemax","-agemin","boattype","sex")
if standards.count()==0:
- standards = CourseStandard.objects.filter(agemin__lt=age,agemax__gt=age)
+ standards = CourseStandard.objects.filter(agemin__lt=age,agemax__gt=age).order_by("agemax","-agemin","boattype","sex")
if standards.count()==0:
# boolean, boattype, boatclass, adaptiveclass, weightclass, sex, coursestandard,
From a128bdd530bdfcabaf8fbf9e1dea6a50778f0050 Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Sun, 21 Jun 2020 18:16:35 +0200
Subject: [PATCH 15/18] lw
---
rowers/plannedsessions.py | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py
index de3698ac..2c649a6b 100644
--- a/rowers/plannedsessions.py
+++ b/rowers/plannedsessions.py
@@ -1379,16 +1379,25 @@ def default_class(r,w,race):
if standards.count()==0:
# omit weight
- standards = CourseStandard.objects.filter(agemin__lt=age,agemax__gt=age,
- boatclass=boatclass,
- adaptiveclass=adaptiveclass,
- boattype=boattype,
- ).order_by("agemax","-agemin","boattype","sex")
+ standards = CourseStandard.objects.filter(
+ agemin__lt=age,agemax__gt=age,
+ boatclass=boatclass,
+ adaptiveclass=adaptiveclass,
+ boattype=boattype,
+ ).order_by(
+ "agemax","-agemin","boattype","sex","weightcategory"
+ )
if standards.count()==0:
- standards = CourseStandard.objects.filter(agemin__lt=age,agemax__gt=age,
- boattype=boattype).order_by("agemax","-agemin","boattype","sex")
+ standards = CourseStandard.objects.filter(
+ agemin__lt=age,agemax__gt=age,
+ boattype=boattype
+ ).order_by(
+ "agemax","-agemin","boattype","sex")
if standards.count()==0:
- standards = CourseStandard.objects.filter(agemin__lt=age,agemax__gt=age).order_by("agemax","-agemin","boattype","sex")
+ standards = CourseStandard.objects.filter(
+ agemin__lt=age,agemax__gt=age
+ ).order_by(
+ "agemax","-agemin","boattype","sex")
if standards.count()==0:
# boolean, boattype, boatclass, adaptiveclass, weightclass, sex, coursestandard,
From c04954daed6467a45e9b6843c2ae73ba7221fd3f Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Sun, 21 Jun 2020 18:19:17 +0200
Subject: [PATCH 16/18] filter by ref speed
---
rowers/plannedsessions.py | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py
index 2c649a6b..7f4d23c0 100644
--- a/rowers/plannedsessions.py
+++ b/rowers/plannedsessions.py
@@ -1385,19 +1385,22 @@ def default_class(r,w,race):
adaptiveclass=adaptiveclass,
boattype=boattype,
).order_by(
- "agemax","-agemin","boattype","sex","weightcategory"
+ "agemax","-agemin","boattype","sex","weightcategory",
+ "referencespeed"
)
if standards.count()==0:
standards = CourseStandard.objects.filter(
agemin__lt=age,agemax__gt=age,
boattype=boattype
).order_by(
- "agemax","-agemin","boattype","sex")
+ "agemax","-agemin","boattype","sex",
+ "weightcategory","referencespeed")
if standards.count()==0:
standards = CourseStandard.objects.filter(
agemin__lt=age,agemax__gt=age
).order_by(
- "agemax","-agemin","boattype","sex")
+ "agemax","-agemin","boattype","sex",
+ "weightcategory","referencespeed")
if standards.count()==0:
# boolean, boattype, boatclass, adaptiveclass, weightclass, sex, coursestandard,
From 745358a2c7f9d9ffb85054e81b57b21ee718c8df Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Mon, 22 Jun 2020 18:36:41 +0200
Subject: [PATCH 17/18] adding aws_region
---
rowsandall_app/settings.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rowsandall_app/settings.py b/rowsandall_app/settings.py
index 04a621a1..aea004aa 100644
--- a/rowsandall_app/settings.py
+++ b/rowsandall_app/settings.py
@@ -379,7 +379,7 @@ CACHE_MIDDLEWARE_SECONDS = 900
EMAIL_BACKEND = 'django_ses.SESBackend'
-AWS_SES_REGION_NAME = CFG['aws_smtp']
+AWS_SES_REGION_NAME = CFG['aws_region']
AWS_SES_REGION_ENDPOINT = CFG['aws_smtp']
AWS_SES_ACCESS_KEY_ID = CFG['aws_access_key_id']
From 7beaec99e999f94a9d68f1a458ea94b9c69a5eb8 Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Mon, 22 Jun 2020 18:46:18 +0200
Subject: [PATCH 18/18] updated reqs.txt
---
requirements.txt | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/requirements.txt b/requirements.txt
index 25b00df6..8da2a8d6 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,6 +3,7 @@ apipkg==1.5
appdirs==1.4.3
arcgis==1.6.0
arrow==0.13.1
+asgiref==3.2.7
asn1crypto==0.24.0
atomicwrites==1.3.0
attrs==19.1.0
@@ -110,7 +111,7 @@ jupyterlab-server==0.3.0
keyring==18.0.0
kiwisolver==1.0.1
kombu==4.5.0
-llvmlite==0.33.0
+llvmlite==0.30.0
lxml==4.3.2
Markdown==3.0.1
MarkupSafe==1.1.1
@@ -128,7 +129,7 @@ newrelic==5.2.1.129
nose==1.3.7
nose-parameterized==0.6.0
notebook==5.7.6
-numba==0.50.0
+numba==0.46.0
numpy==1.18.5
oauth2==1.9.0.post1
oauthlib==3.0.1
@@ -151,7 +152,7 @@ protobuf==3.11.1
psycopg2==2.8.1
ptyprocess==0.6.0
py==1.8.0
-pyarrow==0.17.1
+pyarrow==0.15.0
pycairo==1.19.0
pycparser==2.19
Pygments==2.3.1
@@ -192,7 +193,7 @@ simplejson==3.16.0
six==1.12.0
soupsieve==1.8
SQLAlchemy==1.3.1
-sqlparse==0.3.0
+sqlparse==0.3.1
stravalib==0.10.2
termcolor==1.1.0
terminado==0.8.1