Merge branch 'develop' into feature/warmingups
This commit is contained in:
@@ -34,7 +34,7 @@ class FITParser(BaseParser):
|
||||
return stream.read()
|
||||
except Exception as e:
|
||||
dologging("apilog.log", "FIT Parser")
|
||||
dolofging("apilog.log", e)
|
||||
dologging("apilog.log", e)
|
||||
raise ValueError(f"Failed to read FIT file: {str(e)}")
|
||||
|
||||
return stream.read()
|
||||
@@ -554,9 +554,11 @@ def strokedata_fit(request):
|
||||
return HttpResponseBadRequest("Only POST requests are allowed.")
|
||||
|
||||
|
||||
dologging('apilog.log', request.user.username+" (strokedata_fit POST)")
|
||||
try:
|
||||
fit_data = request.data
|
||||
|
||||
if not fit_data:
|
||||
return HttpResponseBadRequest("No FIT data provided.")
|
||||
# Ensure the media directory exists
|
||||
media_dir = 'media'
|
||||
os.makedirs(media_dir, exist_ok=True)
|
||||
@@ -578,7 +580,8 @@ def strokedata_fit(request):
|
||||
try:
|
||||
# Parse the FIT file
|
||||
try:
|
||||
row = FP(fit_filename)
|
||||
row = FP(fit_filename)
|
||||
dologging('apilog.log','FIT file parsed')
|
||||
except ValueError as e:
|
||||
dologging('apilog.log','FIT error')
|
||||
dologging('apilog.log',e)
|
||||
@@ -619,6 +622,7 @@ def strokedata_fit(request):
|
||||
'rpe': 0,
|
||||
'notes': '',
|
||||
'id': w.id,
|
||||
'workouttype': 'water',
|
||||
'offline': False,
|
||||
}
|
||||
|
||||
@@ -629,11 +633,13 @@ def strokedata_fit(request):
|
||||
url,
|
||||
uploadoptions)
|
||||
|
||||
return JsonResponse(
|
||||
{"status": "success",
|
||||
dologging('apilog.log','FIT file uploaded, returning response')
|
||||
returndict = {
|
||||
"status": "success",
|
||||
"workout public id": encoder.encode_hex(w.id),
|
||||
"workout id": w.id,
|
||||
})
|
||||
}
|
||||
return JsonResponse(returndict, status=201)
|
||||
except Exception as e:
|
||||
dologging('apilog.log','FIT API endpoint')
|
||||
dologging('apilog.log',e)
|
||||
|
||||
Reference in New Issue
Block a user