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 diff --git a/rowers/nkstuff.py b/rowers/nkstuff.py index 95c5ea32..1671c563 100644 --- a/rowers/nkstuff.py +++ b/rowers/nkstuff.py @@ -58,6 +58,7 @@ def get_token(code): # pragma: no cover response = requests.post(url, auth=HTTPBasicAuth(oauth_data['client_id'], oauth_data['client_secret']), data=post_data) + if response.status_code != 200: return [0, response.text, 0, 0] diff --git a/rowers/tests/test_async_tasks.py b/rowers/tests/test_async_tasks.py index 9721356a..daa642e6 100644 --- a/rowers/tests/test_async_tasks.py +++ b/rowers/tests/test_async_tasks.py @@ -221,6 +221,7 @@ class AsyncTaskTests(TestCase): userfirstname = self.u.first_name userlastname = self.u.last_name, rowerfirstname = self.u.first_name, + rowerlastname = self.u.last_name, alertname = 'Test Alert' stats = { 'percentage': 45, @@ -234,7 +235,8 @@ class AsyncTaskTests(TestCase): } res = tasks.handle_send_email_alert(useremail,userfirstname,userlastname, - rowerfirstname,alertname,stats) + rowerfirstname, + rowerlastname,alertname,stats) self.assertEqual(res,1)