diff --git a/rowers/tasks.py b/rowers/tasks.py index 0a0c1354..8cd72879 100644 --- a/rowers/tasks.py +++ b/rowers/tasks.py @@ -102,6 +102,7 @@ import requests import rowers.longtask as longtask import arrow import stravalib +from stravalib.exc import ActivityUploadFailed from rowers.utils import get_strava_stream @@ -171,17 +172,22 @@ def handle_runkeeper_sync(workoutid,url,headers,data,debug=False,**kwargs): @app.task def handle_strava_sync(stravatoken,workoutid,filename,name,activity_type,description,debug=False,**kwargs): client = stravalib.Client(access_token=stravatoken) + failed = False with open(filename,'rb') as f: act = client.upload_activity(f,'tcx.gz',name=name) - res = act.wait(poll_interval=5.0, timeout=60) - try: - act = client.update_activity(res.id,activity_type=activity_type, - description=description,device_name='Rowsandall.com') - except TypeError: - act = client.update_activity(res.id,activity_type=activity_type, - description=description) + try: + res = act.wait(poll_interval=5.0, timeout=60) + except ActivityUploadFailed: + failed = True + if not failed: + try: + act = client.update_activity(res.id,activity_type=activity_type, + description=description,device_name='Rowsandall.com') + except TypeError: + act = client.update_activity(res.id,activity_type=activity_type, + description=description) - result = update_workout_field_sql(workoutid,'uploadedtostrava',res.id,debug=debug) + result = update_workout_field_sql(workoutid,'uploadedtostrava',res.id,debug=debug) try: os.remove(filename) except WindowsError: diff --git a/rowers/templates/plannedsessions_print.html b/rowers/templates/plannedsessions_print.html index b123b6ed..2fa37771 100644 --- a/rowers/templates/plannedsessions_print.html +++ b/rowers/templates/plannedsessions_print.html @@ -32,7 +32,7 @@ Unit{{ ps.sessionunit }} - Comment{{ ps.comment|linebreaks }} + Comment{{ ps.comment|linebreaks|urlshorten:"50" }} {% endfor %} diff --git a/rowers/templates/plannedsessionview.html b/rowers/templates/plannedsessionview.html index 1f2a4889..669878a3 100644 --- a/rowers/templates/plannedsessionview.html +++ b/rowers/templates/plannedsessionview.html @@ -30,7 +30,7 @@ {% if key == attr %} {% if key == 'comment' %} - {{ value.0 }}{{ value.1|linebreaks }} + {{ value.0 }}{{ value.1|linebreaks|urlshorten:"50" }} {% else %} {{ value.0 }}{{ value.1 }} {% endif %}