Private
Public Access
1
0

processing emails from alternate address

This commit is contained in:
Sander Roosendaal
2020-10-07 19:29:17 +02:00
parent b5b2969ef8
commit 3107182310
4 changed files with 58 additions and 16 deletions

View File

@@ -4685,21 +4685,25 @@ def workout_upload_api(request):
if rowerform.is_valid():
u = rowerform.cleaned_data['user']
r = getrower(u)
elif 'useremail' in post_data:
else:
message = {'status':'false','message':'invalid user'}
return JSONResponse(status=400,data=message)
if 'useremail' in post_data:
us = User.objects.filter(email=post_data['useremail'])
if len(us):
u = us[0]
r = getrower(u)
else:
rs = [r for r in Rower.objects.all() if from_address in r.emailalternatives]
if len(rs):
r = rs[0]
else:
r = None
for rwr in Rower.objects.all():
if post_data['useremail'] in rwr.emailalternatives:
r = rwr
break
if post_data['useremail'] not in r.emailalternatives:
message = {'status':'false','message':'could not find user'}
return JSONResponse(status=400,data=message)
else:
message = {'status':'false','message':'invalid user'}
return JSONResponse(status=400,data=message)
notes = form.cleaned_data['notes']
if optionsform.is_valid():
@@ -4716,6 +4720,9 @@ def workout_upload_api(request):
message = optionsform.errors
return JSONResponse(status=400,data=message)
if r is None:
message = {'status':'false','message':'something went wrong'}
return JSONResponse(status=400,data=message)
id, message, f2 = dataprep.new_workout_from_file(
r,f2,