Merge branch 'release/v18.1.15'
This commit is contained in:
@@ -30,7 +30,7 @@ class RowerInline(admin.StackedInline):
|
||||
('Billing Details',
|
||||
{'fields':('street_address','city','postal_code','country','paymentprocessor','customer_id')}),
|
||||
('Rower Plan',
|
||||
{'fields':('paidplan','rowerplan','paymenttype','planexpires','teamplanexpires','protrialexpires','plantrialexpires','clubsize','offercoaching')}),
|
||||
{'fields':('paidplan','rowerplan','paymenttype','planexpires','teamplanexpires','protrialexpires','plantrialexpires','eurocredits','clubsize','offercoaching')}),
|
||||
('Rower Settings',
|
||||
{'fields':
|
||||
('surveydone','surveydonedate','gdproptin','gdproptindate','weightcategory','sex','adaptiveclass','birthdate','getemailnotifications',
|
||||
|
||||
@@ -88,7 +88,7 @@ class Command(BaseCommand):
|
||||
# Polar
|
||||
try:
|
||||
polar_available = polarstuff.get_polar_notifications()
|
||||
# res = polarstuff.get_all_new_workouts(polar_available)
|
||||
res = polarstuff.get_all_new_workouts(polar_available)
|
||||
except: # pragma: no cover
|
||||
exc_type, exc_value, exc_traceback = sys.exc_info()
|
||||
lines = traceback.format_exception(exc_type, exc_value, exc_traceback)
|
||||
|
||||
@@ -70,7 +70,7 @@ from rowers.utils import NoTokenError, custom_exception_handler
|
||||
import rowers.mytypes as mytypes
|
||||
|
||||
# Exchange access code for long-lived access token
|
||||
def get_token(code): # pragma: no cover
|
||||
def get_token(code):
|
||||
|
||||
post_data = {"grant_type": "authorization_code",
|
||||
"code": code,
|
||||
@@ -106,7 +106,7 @@ def get_token(code): # pragma: no cover
|
||||
return [thetoken,expires_in,user_id]
|
||||
|
||||
# Make authorization URL including random string
|
||||
def make_authorization_url(): # pragma: no cover
|
||||
def make_authorization_url():
|
||||
# Generate a random string for the state parameter
|
||||
# Save it for use later to prevent xsrf attacks
|
||||
state = str(uuid4())
|
||||
@@ -121,7 +121,7 @@ def make_authorization_url(): # pragma: no cover
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
def get_polar_notifications(): # pragma: no cover
|
||||
def get_polar_notifications():
|
||||
url = baseurl+'/notifications'
|
||||
state = str(uuid4())
|
||||
auth_string = '{id}:{secret}'.format(
|
||||
@@ -137,7 +137,7 @@ def get_polar_notifications(): # pragma: no cover
|
||||
|
||||
try:
|
||||
response = requests.get(url, headers=headers)
|
||||
except ConnectionError: # pragma: no cover
|
||||
except ConnectionError:
|
||||
response = {
|
||||
'status_code':400,
|
||||
}
|
||||
@@ -160,7 +160,7 @@ def get_polar_notifications(): # pragma: no cover
|
||||
from rowers.rower_rules import ispromember
|
||||
|
||||
def get_all_new_workouts(available_data,testing=False):
|
||||
for record in available_data: # pragma: no cover
|
||||
for record in available_data:
|
||||
dologging('polar.log',str(record))
|
||||
if testing:
|
||||
print(record)
|
||||
@@ -176,7 +176,7 @@ def get_all_new_workouts(available_data,testing=False):
|
||||
except Rower.DoesNotExist:
|
||||
pass
|
||||
|
||||
return 1 # pragma: no cover
|
||||
return 1
|
||||
|
||||
|
||||
def get_polar_workouts(user):
|
||||
@@ -187,11 +187,11 @@ def get_polar_workouts(user):
|
||||
if (r.polartoken == '') or (r.polartoken is None):
|
||||
s = "Token doesn't exist. Need to authorize"
|
||||
return custom_exception_handler(401,s)
|
||||
elif (timezone.now()>r.polartokenexpirydate): # pragma: no cover
|
||||
elif (timezone.now()>r.polartokenexpirydate):
|
||||
s = "Token expired. Needs to refresh"
|
||||
dologging('polar.log',s)
|
||||
return custom_exception_handler(401,s)
|
||||
else: # pragma: no cover
|
||||
else:
|
||||
authorizationstring = str('Bearer ' + r.polartoken)
|
||||
headers = {'Authorization':authorizationstring,
|
||||
'Accept': 'application/json'}
|
||||
@@ -299,11 +299,16 @@ def get_polar_workouts(user):
|
||||
dologging('polar.log',str(exercise_dict))
|
||||
|
||||
# commit transaction
|
||||
#requests.put(url, headers=headers)
|
||||
url = baseurl+'/users/{userid}/exercise-transactions/{transactionid}'.format(
|
||||
transactionid = transactionid,
|
||||
userid = r.polaruserid
|
||||
)
|
||||
requests.put(url, headers=headers)
|
||||
dologging('polar.log','Committed transation at {url}'.format(url=url))
|
||||
|
||||
return exercise_list # pragma: no cover
|
||||
return exercise_list
|
||||
|
||||
def get_polar_user_info(user,physical=False): # pragma: no cover
|
||||
def get_polar_user_info(user,physical=False):
|
||||
r = Rower.objects.get(user=user)
|
||||
if (r.polartoken == '') or (r.polartoken is None):
|
||||
s = "Token doesn't exist. Need to authorize"
|
||||
@@ -341,7 +346,7 @@ def get_polar_user_info(user,physical=False): # pragma: no cover
|
||||
return response
|
||||
|
||||
|
||||
def get_polar_workout(user,id,transactionid): # pragma: no cover
|
||||
def get_polar_workout(user,id,transactionid):
|
||||
|
||||
r = Rower.objects.get(user=user)
|
||||
if (r.polartoken == '') or (r.polartoken is None):
|
||||
|
||||
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Binary file not shown.
Reference in New Issue
Block a user