Private
Public Access
1
0

c2, strava done, almost done st

This commit is contained in:
Sander Roosendaal
2018-07-03 17:02:45 +02:00
parent 3421d1a685
commit ce53c29fee
7 changed files with 242 additions and 45 deletions

View File

@@ -4,7 +4,7 @@
# move that here.)
from rowers.imports import *
import datetime
from requests import Request, Session
from rowers.types import otwtypes
@@ -310,9 +310,9 @@ def createc2workoutdata_as_splits(w):
split_data.append(thisrecord)
try:
durationstr = datetime.strptime(str(w.duration),"%H:%M:%S.%f")
durationstr = datetime.datetime.strptime(str(w.duration),"%H:%M:%S.%f")
except ValueError:
durationstr = datetime.strptime(str(w.duration),"%H:%M:%S")
durationstr = datetime.datetime.strptime(str(w.duration),"%H:%M:%S")
try:
newnotes = w.notes+'\n from '+w.workoutsource+' via rowsandall.com'
@@ -379,13 +379,18 @@ def createc2workoutdata(w):
stroke_data.append(thisrecord)
try:
durationstr = datetime.strptime(str(w.duration),"%H:%M:%S.%f")
durationstr = datetime.datetime.strptime(str(w.duration),"%H:%M:%S.%f")
except ValueError:
durationstr = datetime.strptime(str(w.duration),"%H:%M:%S")
durationstr = datetime.datetime.strptime(str(w.duration),"%H:%M:%S")
workouttype = w.workouttype
if workouttype in otwtypes:
workouttype = 'water'
try:
startdatetime = w.startdatetime.isoformat()
except AttributeError:
startdate = datetime.datetime.combine(w.date,datetime.time())
data = {
"type": workouttype,
@@ -673,7 +678,8 @@ def workout_c2_upload(user,w):
w.save()
elif (response.status_code == 201 or response.status_code == 200):
try:
s= json.loads(response.text)
# s= json.loads(response.text)
s = response.json()
c2id = s['data']['id']
w.uploadedtoc2 = c2id
w.save()
@@ -696,7 +702,7 @@ def rower_c2_token_refresh(user):
access_token = res[0]
expires_in = res[1]
refresh_token = res[2]
expirydatetime = timezone.now()+timedelta(seconds=expires_in)
expirydatetime = timezone.now()+datetime.timedelta(seconds=expires_in)
r = Rower.objects.get(user=user)
r.c2token = access_token