From d4f501d20c31cd2ba3a5dd7a834149dd32869fa0 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Mon, 19 Sep 2022 20:11:01 +0200 Subject: [PATCH] fix --- rowers/models.py | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/rowers/models.py b/rowers/models.py index a8e8516e..048a1fb3 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -3529,26 +3529,32 @@ class Workout(models.Model): workouttype = self.workouttype if workouttype != 'water': - stri = u'{d} {n} {dist}m {duration} {workouttype} {ownerfirst} {ownerlast}'.format( - d=date.strftime('%Y-%m-%d'), - n=name, - dist=distance, - duration=duration.strftime("%H:%M:%S"), - workouttype=workouttype, - ownerfirst=ownerfirst, - ownerlast=ownerlast, - ) + try: + stri = u'{d} {n} {dist}m {duration} {workouttype} {ownerfirst} {ownerlast}'.format( + d=date.strftime('%Y-%m-%d'), + n=name, + dist=distance, + duration=duration.strftime("%H:%M:%S"), + workouttype=workouttype, + ownerfirst=ownerfirst, + ownerlast=ownerlast, + ) + except ValueError: + stri = 'workout' else: - stri = u'{d} {n} {dist}m {duration:%H:%M:%S} {workouttype} {boattype} {ownerfirst} {ownerlast}'.format( - d=date.strftime('%Y-%m-%d'), - n=name, - dist=distance, - duration=duration, - workouttype=workouttype, - boattype=boattype, - ownerfirst=ownerfirst, - ownerlast=ownerlast, - ) + try: + stri = u'{d} {n} {dist}m {duration} {workouttype} {boattype} {ownerfirst} {ownerlast}'.format( + d=date.strftime('%Y-%m-%d'), + n=name, + dist=distance, + duration=duration.strftime("%H:%M:%S"), + workouttype=workouttype, + boattype=boattype, + ownerfirst=ownerfirst, + ownerlast=ownerlast, + ) + except ValueError: + stri = 'workout' return stri