bug fix fastest distance race
This commit is contained in:
@@ -1142,6 +1142,12 @@ def update_indoorvirtualrace(ps,cd):
|
||||
|
||||
ps.timezone = timezone_str
|
||||
|
||||
if ps.sessiontype == 'fastest_distance':
|
||||
ps.approximate_distance = ps.sessionvalue
|
||||
|
||||
if ps.course is not None:
|
||||
ps.approximate_distance = ps.course.distance
|
||||
|
||||
ps.save()
|
||||
|
||||
return 1,'Virtual Race Updated'
|
||||
@@ -1195,6 +1201,12 @@ def update_virtualrace(ps,cd):
|
||||
|
||||
ps.timezone = timezone_str
|
||||
|
||||
if ps.sessiontype == 'fastest_distance':
|
||||
ps.approximate_distance = ps.sessionvalue
|
||||
|
||||
if ps.course is not None:
|
||||
ps.approximate_distance = ps.course.distance
|
||||
|
||||
ps.save()
|
||||
|
||||
return 1,'Virtual Race Updated'
|
||||
@@ -1685,6 +1697,7 @@ def add_workout_fastestrace(ws, race, r, recordid=0, doregister=False):
|
||||
ids = [w.id for w in ws]
|
||||
ids = list(set(ids))
|
||||
|
||||
|
||||
if len(ids)>1 and race.sessiontype in ['test','coursetest','race','indoorrace','fastest_time','fastest_distance']: # pragma: no cover
|
||||
errors.append('For tests, you can only attach one workout')
|
||||
return result,comments,errors,0
|
||||
@@ -1725,10 +1738,12 @@ def add_workout_fastestrace(ws, race, r, recordid=0, doregister=False):
|
||||
errors.append("Couldn't find this entry")
|
||||
return result,comments,errors,0
|
||||
|
||||
|
||||
|
||||
records = IndoorVirtualRaceResult.objects.filter(
|
||||
userid=r.id,
|
||||
race=race,
|
||||
workoutid = ws[0].id
|
||||
#workoutid = ws[0].id
|
||||
)
|
||||
|
||||
if ws[0].workouttype != record.boatclass: # pragma: no cover
|
||||
@@ -1757,8 +1772,14 @@ def add_workout_fastestrace(ws, race, r, recordid=0, doregister=False):
|
||||
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: # pragma: no cover
|
||||
oldworkouts = Workout.objects.filter(plannedsession=race)
|
||||
for oldworkout in oldworkouts:
|
||||
oldworkout.plannedsession = None
|
||||
oldworkout.save()
|
||||
|
||||
otherrecord.workoutid = None
|
||||
otherrecord.coursecompleted = False
|
||||
otherrecord.save()
|
||||
|
||||
Reference in New Issue
Block a user