Private
Public Access
1
0

more or less done

This commit is contained in:
2024-12-05 21:05:42 +01:00
parent 13effe6cce
commit 4d8aad12af
8 changed files with 154 additions and 12 deletions

View File

@@ -1597,13 +1597,28 @@ def add_workout_fastestrace(ws, race, r, recordid=0, doregister=False):
enddatetime
)
# from ws, remove any w where w.workoutsource = 'strava'. For each removal add an error "strava workout not permitted" to the errors list and if there are no workouts left, return 0, comments, errors, 0
ws2 = []
for w in ws:
if w.workoutsource != 'strava':
ws2.append(w)
else:
errors.append('Strava workouts are not permitted')
ws = ws2
if len(ws) == 0:
return result, comments, errors, 0
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
if r.birthdate:
age = calculate_age(r.birthdate)
else: # pragma: no cover
@@ -1759,6 +1774,19 @@ def add_workout_indoorrace(ws, race, r, recordid=0, doregister=False):
enddatetime
)
# from ws, remove any w where w.workoutsource = 'strava'. For each removal add an error "strava workout not permitted" to the errors list and if there are no workouts left, return 0, comments, errors, 0
ws2 = []
for w in ws:
if w.workoutsource != 'strava':
ws2.append(w)
else:
errors.append('Strava workouts are not permitted')
ws = ws2
if len(ws) == 0:
return result, comments, errors, 0
# check if all sessions have same date
dates = [w.date for w in ws]
if (not all(d == dates[0] for d in dates)) and race.sessiontype not in ['challenge', 'cycletarget']: # pragma: no cover
@@ -1906,6 +1934,19 @@ def add_workout_race(ws, race, r, splitsecond=0, recordid=0, doregister=False):
enddatetime
)
# from ws, remove any w where w.workoutsource = 'strava'. For each removal add an error "strava workout not permitted" to the errors list and if there are no workouts left, return 0, comments, errors, 0
ws2 = []
for w in ws:
if w.workoutsource != 'strava':
ws2.append(w)
else:
errors.append('Strava workouts are not permitted')
ws = ws2
if len(ws) == 0:
return result, comments, errors, 0
# check if all sessions have same date
dates = [w.date for w in ws]
if (not all(d == dates[0] for d in dates)) and race.sessiontype not in ['challenge', 'cycletarget']: # pragma: no cover