workouttype mapping for C2
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
from rowers.imports import *
|
||||
import datetime
|
||||
from requests import Request, Session
|
||||
|
||||
import mytypes
|
||||
from rowers.mytypes import otwtypes
|
||||
from iso8601 import ParseError
|
||||
|
||||
@@ -428,7 +428,7 @@ def createc2workoutdata(w):
|
||||
startdate = datetime.datetime.combine(w.date,datetime.time())
|
||||
|
||||
data = {
|
||||
"type": workouttype,
|
||||
"type": mytypes.c2mapping[workouttype],
|
||||
"date": w.startdatetime.isoformat(),
|
||||
"timezone": w.timezone,
|
||||
"distance": int(w.distance),
|
||||
@@ -684,6 +684,9 @@ def process_callback(request):
|
||||
# Uploading workout
|
||||
def workout_c2_upload(user,w):
|
||||
message = 'trying C2 upload'
|
||||
if mytypes.c2mapping[w.workouttype] is None:
|
||||
return "This workout type cannot be uploaded to Concept2",0
|
||||
|
||||
thetoken = c2_open(user)
|
||||
|
||||
r = Rower.objects.get(user=user)
|
||||
@@ -755,7 +758,7 @@ def add_workout_from_data(user,importid,data,strokedata,
|
||||
source='c2',splitdata=None,
|
||||
workoutsource='concept2'):
|
||||
try:
|
||||
workouttype = data['type']
|
||||
workouttype = mytypes.c2mappinginv[data['type']]
|
||||
except KeyError:
|
||||
workouttype = 'rower'
|
||||
|
||||
|
||||
@@ -41,6 +41,52 @@ workouttypes = (
|
||||
('other','Other'),
|
||||
)
|
||||
|
||||
c2mapping = {
|
||||
'water':'water',
|
||||
'rower':'rower',
|
||||
'skierg':'skierg',
|
||||
'bike':'bike',
|
||||
'dynamic':'dynamic',
|
||||
'slides':'slides',
|
||||
'paddle':'paddle',
|
||||
'snow':'snow',
|
||||
'coastal':'water',
|
||||
'c-boat':'water',
|
||||
'churchboat':'water',
|
||||
'Ride':'bike',
|
||||
'Kitesurf':None,
|
||||
'Run':None,
|
||||
'NordicSki':'snow',
|
||||
'Swim':None,
|
||||
'RockClimbing':None,
|
||||
'Hike':None,
|
||||
'RollerSki':'snow',
|
||||
'Walk':None,
|
||||
'AlpineSki':None,
|
||||
'Snowboard':None,
|
||||
'BackcountrySki':'snow',
|
||||
'Snowshoe':'snow',
|
||||
'Canoeing':'paddle',
|
||||
'StairStepper':None,
|
||||
'Crossfit':None,
|
||||
'StandUpPaddling':None,
|
||||
'EBikeRide':None,
|
||||
'Surfing':None,
|
||||
'Elliptical':None,
|
||||
'VirtualRide':None,
|
||||
'IceSkate':None,
|
||||
'WeightTraining':None,
|
||||
'InlineSkate':None,
|
||||
'Windsurf':None,
|
||||
'Kayaking':None,
|
||||
'Workout':None,
|
||||
'Yoga':None,
|
||||
'other':None,
|
||||
|
||||
}
|
||||
|
||||
c2mappinginv = {value:key for key,value in c2mapping.iteritems() if value is not None}
|
||||
|
||||
otwtypes = (
|
||||
'water',
|
||||
'coastal',
|
||||
|
||||
@@ -10822,7 +10822,7 @@ def workout_getimportview(request,externalid,source = 'c2'):
|
||||
if strokedata.empty:
|
||||
distance = data['distance']
|
||||
c2id = data['id']
|
||||
workouttype = data['type']
|
||||
workouttype = mytypes.c2mappinginv[data['type']]
|
||||
verified = data['verified']
|
||||
startdatetime = iso8601.parse_date(data['date'])
|
||||
weightclass = data['weight_class']
|
||||
|
||||
Reference in New Issue
Block a user