garmin files - not working
This commit is contained in:
@@ -110,6 +110,15 @@ def garmin_open(user):
|
|||||||
|
|
||||||
return token
|
return token
|
||||||
|
|
||||||
|
def get_garmin_file(r,callbackURL,starttime):
|
||||||
|
garmin = OAuth1Session(oauth_data['client_id'],
|
||||||
|
client_secret=oauth_data['client_secret'],
|
||||||
|
resource_owner_key=r.garmintoken,
|
||||||
|
resource_owner_secret=r.garminrefreshtoken,
|
||||||
|
)
|
||||||
|
response = garmin.get(callbackURL)
|
||||||
|
return 1
|
||||||
|
|
||||||
def get_garmin_workout_list(user):
|
def get_garmin_workout_list(user):
|
||||||
r = Rower.objects.get(user=user)
|
r = Rower.objects.get(user=user)
|
||||||
if (r.garmintoken == '') or (r.stravatoken is None):
|
if (r.garmintoken == '') or (r.stravatoken is None):
|
||||||
|
|||||||
@@ -1031,6 +1031,37 @@ def garmin_summaries_view(request):
|
|||||||
|
|
||||||
return HttpResponse(status=200)
|
return HttpResponse(status=200)
|
||||||
|
|
||||||
|
@csrf_exempt
|
||||||
|
def garmin_newfiles_ping(request):
|
||||||
|
t = time.localtime()
|
||||||
|
timestamp = time.strftime('%b-%d-%Y_%H%M', t)
|
||||||
|
with open('garminlog.log','a') as f:
|
||||||
|
f.write('\n')
|
||||||
|
f.write(timestamp)
|
||||||
|
f.write(' ')
|
||||||
|
f.write(str(request.body))
|
||||||
|
|
||||||
|
if request.method != 'POST':
|
||||||
|
return HttpResponse(status=200)
|
||||||
|
|
||||||
|
data = json.loads(request.body)
|
||||||
|
files = data['activityFiles']
|
||||||
|
for file in data['activityFiles']:
|
||||||
|
try:
|
||||||
|
garmintoken = file['userAccessToken']
|
||||||
|
try:
|
||||||
|
r = Rower.objects.get(garmintoken=garmintoken
|
||||||
|
)
|
||||||
|
callbackURL = file['callbackURL']
|
||||||
|
starttime = file['startTimeInSeconds']
|
||||||
|
job = get_garmin_file(r,callbackURL,starttime)
|
||||||
|
except Rower.DoesNotExist:
|
||||||
|
pass
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return HttpResponse(status=200)
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
def garmin_deregistration_view(request):
|
def garmin_deregistration_view(request):
|
||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
|
|||||||
Reference in New Issue
Block a user