From 00539db3357681428052f050673aa8c8f8ea1724 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Wed, 14 Nov 2018 21:58:15 +0100 Subject: [PATCH] progressing --- rowers/mytypes.py | 182 +++++++++++++++++++++++++++++++++++++++++++ rowers/polarstuff.py | 2 +- rowers/views.py | 10 +-- 3 files changed, 184 insertions(+), 10 deletions(-) diff --git a/rowers/mytypes.py b/rowers/mytypes.py index 8d2c861b..c38a6602 100644 --- a/rowers/mytypes.py +++ b/rowers/mytypes.py @@ -85,6 +85,182 @@ stravamapping = { } +stmapping = { + 'water':'Rowing', + 'rower':'Rowing', + 'skierg':'Skiing:Nordic', + 'bike':'Cycling', + 'dynamic':'Rowing', + 'slides':'Rowing', + 'paddle':'Other:Paddling', + 'snow':'Skiing:Nordic', + 'coastal':'Rowing', + 'c-boat':'Rowing', + 'churchboat':'Rowing', + 'Ride':'Cycling', + 'Kitesurf':'Other:Kitesurf', + 'Run':'Running', + 'NordicSki':'Skiing:Nordic', + 'Swim':'Swimming', + 'RockClimbing':'Other:RockClimbing', + 'Hike':'Hiking', + 'RollerSki':'Other:RollerSki', + 'Walk':'Other:Walk', + 'AlpineSki':'Skiing:AlpineSki', + 'Snowboard':'Other:Snowboard', + 'BackcountrySki':'Skiing:BackcountrySki', + 'Snowshoe':'Other:Snowshoe', + 'Canoeing':'Other:Canoeing', + 'StairStepper':'Other:StairStepper', + 'Crossfit':'Other:Crossfit', + 'StandUpPaddling':'Other:StandUpPaddling', + 'EBikeRide':'Cycling:EBikeRide', + 'Surfing':'Other:Surfing', + 'Elliptical':'Other:Elliptical', + 'VirtualRide':'Cycling:VirtualRide', + 'IceSkate':'Skating', + 'WeightTraining':'Other:WeightTraining', + 'InlineSkate':'Skating:InlineSkate', + 'Windsurf':'Other:Windsurf', + 'Kayaking':'Other:Kayaking', + 'Workout':'Other:Workout', + 'Yoga':'Other:Yoga', + 'other':'Other', + + } + +rkmapping = { + 'water':'Rowing', + 'rower':'Rowing', + 'skierg':'Cross-Country Skiing', + 'bike':'Cycling', + 'dynamic':'Rowing', + 'slides':'Rowing', + 'paddle':'Other:Paddling', + 'snow':'Cross-Country Skiing', + 'coastal':'Rowing', + 'c-boat':'Rowing', + 'churchboat':'Rowing', + 'Ride':'Cycling', + 'Kitesurf':'Other', + 'Run':'Running', + 'NordicSki':'Cross-Country Skiing', + 'Swim':'Swimming', + 'RockClimbing':'Other', + 'Hike':'Hiking', + 'RollerSki':'Other:RollerSki', + 'Walk':'Walking', + 'AlpineSki':'Downhill Skiing', + 'Snowboard':'Snowboarding', + 'BackcountrySki':'Downhill Skiing', + 'Snowshoe':'Other', + 'Canoeing':'Other', + 'StairStepper':'Stairmaster', + 'Crossfit':'CrossFit', + 'StandUpPaddling':'Other', + 'EBikeRide':'Cycling', + 'Surfing':'Other', + 'Elliptical':'Elliptical', + 'VirtualRide':'Cycling', + 'IceSkate':'Skating', + 'WeightTraining':'Other', + 'InlineSkate':'Skating', + 'Windsurf':'Other', + 'Kayaking':'Other', + 'Workout':'Other', + 'Yoga':'Yoga', + 'other':'Other', + + } + +polarmapping = { + 'water':'Rowing', + 'rower':'Rowing', + 'skierg':'Skiing', + 'bike':'Cycling', + 'dynamic':'Rowing', + 'slides':'Rowing', + 'paddle':'Other Outdoor', + 'snow':'Skiing', + 'coastal':'Rowing', + 'c-boat':'Rowing', + 'churchboat':'Rowing', + 'Ride':'Cycling', + 'Kitesurf':'Kitesurfing', + 'Run':'Running', + 'NordicSki':'Skiing', + 'Swim':'Swimming', + 'RockClimbing':'Other Outdoor', + 'Hike':'Hiking', + 'RollerSki':'Other Outdoor', + 'Walk':'Walking', + 'AlpineSki':'Downhill skiing', + 'Snowboard':'Snowboarding', + 'BackcountrySki':'Downhill skiing', + 'Snowshoe':'Snowshoe trekking', + 'Canoeing':'Canoeing', + 'StairStepper':'Other Indoor', + 'Crossfit':'Crossfit', + 'StandUpPaddling':'Other Outdoor', + 'EBikeRide':'Cycling', + 'Surfing':'Surfing', + 'Elliptical':'Other Indoor', + 'VirtualRide':'Cycling', + 'IceSkate':'Skating', + 'WeightTraining':'Other Indoor', + 'InlineSkate':'Skating', + 'Windsurf':'Windsurfing', + 'Kayaking':'Kayaking', + 'Workout':'Other Indoor', + 'Yoga':'Yoga', + 'other':'Other Indoor', + + } + +tpmapping = { + 'water':'rowing', + 'rower':'rowing', + 'skierg':'xc-ski', + 'bike':'bike', + 'dynamic':'rowing', + 'slides':'rowing', + 'paddle':'other', + 'snow':'xc-ski', + 'coastal':'rowing', + 'c-boat':'rowing', + 'churchboat':'rowing', + 'Ride':'cycling', + 'Kitesurf':'other', + 'Run':'run', + 'NordicSki':'xc-ski', + 'Swim':'swim', + 'RockClimbing':'other', + 'Hike':'other', + 'RollerSki':'other', + 'Walk':'walk', + 'AlpineSki':'other', + 'Snowboard':'other', + 'BackcountrySki':'other', + 'Snowshoe':'other', + 'Canoeing':'other', + 'StairStepper':'other', + 'Crossfit':'other', + 'StandUpPaddling':'other', + 'EBikeRide':'other', + 'Surfing':'other', + 'Elliptical':'other', + 'VirtualRide':'bike', + 'IceSkate':'other', + 'WeightTraining':'strength', + 'InlineSkate':'other', + 'Windsurf':'other', + 'Kayaking':'other', + 'Workout':'other', + 'Yoga':'other', + 'other':'other', + + } + c2mapping = { 'water':'water', 'rower':'rower', @@ -133,6 +309,12 @@ c2mappinginv = {value:key for key,value in c2mapping.iteritems() if value is not stravamappinginv = {value:key for key,value in stravamapping.iteritems() if value is not None} +stmappinginv = {value:key for key,value in stmapping.iteritems() if value is not None} + +rkmappinginv = {value:key for key,value in rkmapping.iteritems() if value is not None} + +polarmappinginv = {value:key for key,value in polarmapping.iteritems() if value is not None} + otwtypes = ( 'water', 'coastal', diff --git a/rowers/polarstuff.py b/rowers/polarstuff.py index a1962bcc..e6fe6025 100644 --- a/rowers/polarstuff.py +++ b/rowers/polarstuff.py @@ -52,7 +52,7 @@ baseurl = 'https://polaraccesslink.com/v3' from utils import NoTokenError, custom_exception_handler - +import mytypes # Exchange access code for long-lived access token def get_token(code): diff --git a/rowers/views.py b/rowers/views.py index f84417c3..98fb7c0c 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -10475,15 +10475,7 @@ def workout_runkeeperimport_view(request,message="",userid=0): def workout_underarmourimport_view(request,message="",userid=0): res = underarmourstuff.get_underarmour_workout_list(request.user) if (res.status_code != 200): - if (res.status_code == 401): - r = getrower(request.user) - if (r.underarmourtoken == '') or (r.underarmourtoken is None): - s = "Token doesn't exist. Need to authorize" - return HttpResponseRedirect("/rowers/me/underarmourauthorize/") - message = "Something went wrong in workout_underarmourimport_view" - messages.error(request,message) - url = reverse(workouts_view) - return HttpResponseRedirect(url) + return HttpResponseRedirect("/rowers/me/underarmourauthorize/") workouts = [] items = res.json()['_embedded']['workouts']