Private
Public Access
1
0

Alternative way to check if C2 log has stroke data

This commit is contained in:
Sander Roosendaal
2017-01-06 08:46:54 +01:00
parent 9c72e419f6
commit d02fb441ed
2 changed files with 29 additions and 39 deletions

BIN
logos/boatcoachlogo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@@ -342,17 +342,6 @@ def add_workout_from_strokedata(user,importid,data,strokedata,source='c2'):
rowdatetime = iso8601.parse_date(data['start_date'])
except ParseError:
rowdatetime = iso8601.parse_date(data['date'])
# try:
# rowdatetime = datetime.datetime.strptime(data['date_utc'],"%Y-%m-%d %H:%M:%S")
# rowdatetime = thetimezone.localize(rowdatetime).astimezone(utc)
# except KeyError:
# try:
# rowdatetime = dateutil.parser.parse(data['start_date'])
# rowdatetime = thetimezone.localize(rowdatetime).astimezone(utc)
# except:
# rowdatetime = datetime.datetime.strptime(data['date'],"%Y-%m-%d %H:%M:%S")
# rowdatetime = thetimezone.localize(rowdatetime).astimezone(utc)
try:
@@ -2337,6 +2326,9 @@ def workout_wind_view(request,id=0,message="",successmessage=""):
except KeyError:
hascoordinates = 0
if not latitude.std():
hascoordinates = 0
try:
bearing = rowdata.df.ix[:,'bearing'].values
except KeyError:
@@ -3154,6 +3146,9 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
else:
hascoordinates = 0
if not latitude.std():
hascoordinates = 0
if hascoordinates:
res = googlemap_chart(rowdata.df[' latitude'],
rowdata.df[' longitude'],
@@ -3691,10 +3686,8 @@ def workout_getc2workout_view(request,c2id):
res = c2stuff.get_c2_workout(request.user,c2id)
if (res.status_code == 200):
data = res.json()['data']
if 'stroke_data' in data:
# test = data['stroke_data']
res2 = c2stuff.get_c2_workout_strokes(request.user,c2id)
# 2016-07-27 added below if statement (balkanboy error report)
if res2.status_code == 200:
strokedata = pd.DataFrame.from_dict(res2.json()['data'])
id = add_workout_from_strokedata(request.user,c2id,data,strokedata,
@@ -3705,17 +3698,14 @@ def workout_getc2workout_view(request,c2id):
url = "/rowers/workout/"+str(id)+"/edit"
return HttpResponseRedirect(url)
else:
message = json.loads(s.text)['message']
# message = json.loads(s.text)['message']
message = json.loads(res2.text)['message']
url = reverse(workout_c2import_view,
kwargs={
'message':message,
})
return HttpResponseRedirect(url)
else:
message = "This workout doesn't contain stroke data"
if settings.DEBUG:
return HttpResponse(res)
else:
url = reverse(workout_c2import_view,
kwargs={
'message':message,