v1 using basic auth
This commit is contained in:
@@ -21,6 +21,8 @@ import rowingdata.tcxtools as tcxtools
|
||||
from rowingdata import TCXParser, rowingdata
|
||||
import arrow
|
||||
|
||||
import base64
|
||||
|
||||
class XMLParser(BaseParser):
|
||||
media_type = "application/xml"
|
||||
|
||||
@@ -422,6 +424,52 @@ def get_crewnerd_liked(request):
|
||||
|
||||
# Stroke data views
|
||||
|
||||
@csrf_exempt
|
||||
@logged_in_or_basicauth()
|
||||
def strokedata_rowingdata(request):
|
||||
"""
|
||||
Upload a .csv file (rowingdata standard) through API, using Basic Auth
|
||||
"""
|
||||
r = getrower(request.user)
|
||||
if r.rowerplan == 'freecoach':
|
||||
return HttpResponseNotAllowed("This endpoint is for users, not for free coach accounts")
|
||||
|
||||
if request.method == 'POST':
|
||||
form = DocumentsForm(request.POST, request.FILES)
|
||||
if not form.is_valid():
|
||||
return HttpResponseBadRequest(json.dumps(form.errors))
|
||||
|
||||
f = form.cleaned_data['file']
|
||||
if f is None:
|
||||
return HttpResponseBadRequest("Missing file")
|
||||
|
||||
filename, completefilename = handle_uploaded_file(f)
|
||||
|
||||
uploadoptions = {
|
||||
'secret': settings.UPLOAD_SERVICE_SECRET,
|
||||
'user': r.user.id,
|
||||
'file': completefilename,
|
||||
'workouttype': form.cleaned_data['workouttype'],
|
||||
'boattype': form.cleaned_data['boattype'],
|
||||
'title': form.cleaned_data['title'],
|
||||
'rpe': form.cleaned_data['rpe'],
|
||||
'notes': form.cleaned_data['notes']
|
||||
}
|
||||
|
||||
url = settings.UPLOAD_SERVICE_URL
|
||||
|
||||
_ = myqueue(queuehigh,
|
||||
handle_request_post,
|
||||
url,
|
||||
uploadoptions)
|
||||
|
||||
return JsonResponse(
|
||||
{
|
||||
"status": "success",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@csrf_exempt
|
||||
#@login_required()
|
||||
@api_view(["POST"])
|
||||
|
||||
Reference in New Issue
Block a user