diff --git a/rowers/rows.py b/rowers/rows.py index 2aed8e12..642b0593 100644 --- a/rowers/rows.py +++ b/rowers/rows.py @@ -5,11 +5,11 @@ import hashlib from django.core.exceptions import ValidationError def format_pace_tick(x,pos=None): - min=int(x/60) - sec=int(x-min*60.) + minu=int(x/60) + sec=int(x-minu*60.) sec_str=str(sec).zfill(2) template='%d:%s' - return template % (min,sec_str) + return template % (minu,sec_str) def format_time_tick(x,pos=None): hour=int(x/3600) @@ -109,12 +109,15 @@ def handle_uploaded_image(i): hsize = int((float(image.size[1])*float(wpercent))) image = image.resize((basewidth,hsize), Image.ANTIALIAS) - if exif[orientation] == 3: - image=image.rotate(180, expand=True) - elif exif[orientation] == 6: - image=image.rotate(270, expand=True) - elif exif[orientation] == 8: - image=image.rotate(90, expand=True) + try: + if exif[orientation] == 3: + image=image.rotate(180, expand=True) + elif exif[orientation] == 6: + image=image.rotate(270, expand=True) + elif exif[orientation] == 8: + image=image.rotate(90, expand=True) + except KeyError: + pass filename = hashlib.md5(imagefile.getvalue()).hexdigest()+'.jpg' diff --git a/rowers/views.py b/rowers/views.py index e4fe017a..1823f72e 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -9207,7 +9207,12 @@ def workout_stravaimport_view(request,message=""): start_date = item['start_date'] stravaid = item['id'] if arrow.get(start_date) == arrow.get(w.startdatetime): - if datetime.time(seconds=int(elapsed_time)) == w.duration: + elapsed_td = datetime.timedelta(seconds=int(elapsed_time)) + elapsed_time = datetime.datetime.strptime( + str(elapsed_td), + "%H:%M:%S" + ) + if str(elapsed_time)[-7:] == str(w.duration)[-7:]: w.uploadedtostrava = int(stravaid) w.save()