Private
Public Access
1
0

fixing zip - without uploadoptions

This commit is contained in:
Sander Roosendaal
2020-02-18 20:54:43 +01:00
parent 80b4a26667
commit fc6dd7e347
4 changed files with 16 additions and 24 deletions

View File

@@ -1470,7 +1470,7 @@ def new_workout_from_file(r, f2,
boattype='1x',
makeprivate=False,
notes=''):
message = None
message = ""
impeller = False
try:
fileformat = get_file_type(f2)
@@ -1495,6 +1495,7 @@ def new_workout_from_file(r, f2,
f3 = f3[6:]
a = MessageAttachment(message=msg,document=f3)
a.save()
message = "Zip file was stored for offline processing"
return -1, message, f2

View File

@@ -94,15 +94,11 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
uploadoptions['file'] = 'media/'+filename
uploadoptions['title'] = title
try:
print("Stravaid ",uploadoptions['stravaid'])
except KeyError:
pass
url = settings.UPLOAD_SERVICE_URL
if not testing:
response = requests.post(url,data=uploadoptions)
# print("Upload response status code",response.status_code, response.json())
if response.status_code == 200:
response_json = response.json()
workoutid = [int(response_json['id'])]
@@ -137,21 +133,6 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
if testing:
print('Workout id = {workoutid}'.format(workoutid=workoutid))
# if workoutid[0]:
# link = settings.SITE_URL+reverse(
# therower.defaultlandingpage,
# kwargs = {
# 'id':encoder.encode_hex(workoutid[0]),
# }
# )
#
# if not testing:
# if therower.getemailnotifications and not therower.emailbounced:
# email_sent = send_confirm(
# therower.user, title, link,
# uploadoptions
# )
return workoutid
def get_from_address(message):
@@ -272,6 +253,7 @@ class Command(BaseCommand):
rower, datafile, title, uploadoptions,
testing=testing
)
print(workoutid)
except:
print("Bad ZIP file")
print(attachment.document.name)

View File

@@ -352,7 +352,10 @@ def getboolean(uploadoptions,value,key):
return uploadoptions
def upload_options(body):
uploadoptions = {}
uploadoptions = {
'boattype':'1x',
'workouttype': 'rower',
}
body = cleanbody(body)
try:
yml = (yaml.safe_load(body))

View File

@@ -4493,9 +4493,15 @@ def workout_upload_api(request):
notes=notes,
)
if id <= 0:
message = {'status':'false','message':'unable to process file'+message}
if id == 0:
if message is not None:
message = {'status':'false','message':'unable to process file'+message}
else:
message = {'status': 'false', 'message': 'unable to process file'}
return JSONResponse(status=400,data=message)
if id == -1:
message = {'status': 'true', 'message':message}
return JSONResponse(status=200,data=message)
w = Workout.objects.get(id=id)
if len(stravaid)>0: