Private
Public Access
1
0

register multiple disciplines

This commit is contained in:
Sander Roosendaal
2018-06-01 12:25:36 +02:00
parent 3998c7dded
commit 25249f4b53
7 changed files with 246 additions and 65 deletions

View File

@@ -651,6 +651,32 @@ def race_can_resubmit(r,race):
return False
def race_can_adddiscipline(r,race):
if r not in race.rower.all():
return False
start_time = race.start_time
start_date = race.startdate
startdatetime = datetime.combine(start_date,start_time)
startdatetime = pytz.timezone(race.timezone).localize(
startdatetime
)
evaluation_closure = race.evaluation_closure
if timezone.now() < evaluation_closure:
is_complete,has_registered = race_rower_status(r,race)
if has_registered:
return True
else:
return False
else:
return False
return False
def race_can_withdraw(r,race):
if r not in race.rower.all():
return False
@@ -699,20 +725,25 @@ def add_rower_race(r,race):
return 1
def remove_rower_race(r,race):
def remove_rower_race(r,race,recordid=None):
race.rower.remove(r)
records = VirtualRaceResult.objects.filter(userid=r.id,
workoutid__isnull=True,
race=race)
if recordid:
records = VirtualRaceResult.objects.filter(userid=r.id,
workoutid__isnull=True,
race=race,
id=recordid)
else:
records = VirtualRaceResult.objects.filter(userid=r.id,
workoutid__isnull=True,
race=race,)
for r in records:
r.delete()
return 1
# Low Level functions - to be called by higher level methods
def add_workout_race(ws,race,r,splitsecond=0):
def add_workout_race(ws,race,r,splitsecond=0,recordid=0):
result = 0
comments = []
errors = []
@@ -758,12 +789,21 @@ def add_workout_race(ws,race,r,splitsecond=0):
else:
age = None
record = VirtualRaceResult.objects.get(
userid=r.id,
race=race,
id=recordid
)
records = VirtualRaceResult.objects.filter(
userid=r.id,
race=race
)
record = records[0]
race=race,
workoutid = ws[0].id
)
if not record:
errors.append("Couldn't find this entry")
return result,comments,errors,0
if ws[0].boattype != record.boattype:
errors.append('Your workout boat type did not match the boat type you registered')
@@ -774,18 +814,22 @@ def add_workout_race(ws,race,r,splitsecond=0):
return 0,comments, errors,0
# start adding sessions
for w in ws:
if w.startdatetime>=startdatetime and w.startdatetime<=enddatetime:
w.plannedsession = race
w.save()
result += 1
if ws[0].startdatetime>=startdatetime and ws[0].startdatetime<=enddatetime:
ws[0].plannedsession = race
ws[0].save()
result += 1
else:
errors.append('Workout %i did not match the race window' % w.id)
return result,comments,errors,0
else:
errors.append('Workout %i did not match the race window' % ws[0].id)
return result,comments,errors,0
if result>0:
for otherrecord in records:
print otherrecord
otherrecord.workoutid = None
otherrecord.coursecompleted = False
otherrecord.save()
job = myqueue(queue,handle_check_race_course,ws[0].csvfilename,
ws[0].id,race.course.id,record.id,splitsecond=splitsecond)