fixing zip - without uploadoptions
This commit is contained in:
@@ -1470,7 +1470,7 @@ def new_workout_from_file(r, f2,
|
|||||||
boattype='1x',
|
boattype='1x',
|
||||||
makeprivate=False,
|
makeprivate=False,
|
||||||
notes=''):
|
notes=''):
|
||||||
message = None
|
message = ""
|
||||||
impeller = False
|
impeller = False
|
||||||
try:
|
try:
|
||||||
fileformat = get_file_type(f2)
|
fileformat = get_file_type(f2)
|
||||||
@@ -1495,6 +1495,7 @@ def new_workout_from_file(r, f2,
|
|||||||
f3 = f3[6:]
|
f3 = f3[6:]
|
||||||
a = MessageAttachment(message=msg,document=f3)
|
a = MessageAttachment(message=msg,document=f3)
|
||||||
a.save()
|
a.save()
|
||||||
|
message = "Zip file was stored for offline processing"
|
||||||
|
|
||||||
return -1, message, f2
|
return -1, message, f2
|
||||||
|
|
||||||
|
|||||||
@@ -94,15 +94,11 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
|
|||||||
uploadoptions['file'] = 'media/'+filename
|
uploadoptions['file'] = 'media/'+filename
|
||||||
uploadoptions['title'] = title
|
uploadoptions['title'] = title
|
||||||
|
|
||||||
try:
|
|
||||||
print("Stravaid ",uploadoptions['stravaid'])
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
url = settings.UPLOAD_SERVICE_URL
|
url = settings.UPLOAD_SERVICE_URL
|
||||||
if not testing:
|
if not testing:
|
||||||
response = requests.post(url,data=uploadoptions)
|
response = requests.post(url,data=uploadoptions)
|
||||||
|
# print("Upload response status code",response.status_code, response.json())
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
response_json = response.json()
|
response_json = response.json()
|
||||||
workoutid = [int(response_json['id'])]
|
workoutid = [int(response_json['id'])]
|
||||||
@@ -137,21 +133,6 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
|
|||||||
if testing:
|
if testing:
|
||||||
print('Workout id = {workoutid}'.format(workoutid=workoutid))
|
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
|
return workoutid
|
||||||
|
|
||||||
def get_from_address(message):
|
def get_from_address(message):
|
||||||
@@ -272,6 +253,7 @@ class Command(BaseCommand):
|
|||||||
rower, datafile, title, uploadoptions,
|
rower, datafile, title, uploadoptions,
|
||||||
testing=testing
|
testing=testing
|
||||||
)
|
)
|
||||||
|
print(workoutid)
|
||||||
except:
|
except:
|
||||||
print("Bad ZIP file")
|
print("Bad ZIP file")
|
||||||
print(attachment.document.name)
|
print(attachment.document.name)
|
||||||
|
|||||||
@@ -352,7 +352,10 @@ def getboolean(uploadoptions,value,key):
|
|||||||
return uploadoptions
|
return uploadoptions
|
||||||
|
|
||||||
def upload_options(body):
|
def upload_options(body):
|
||||||
uploadoptions = {}
|
uploadoptions = {
|
||||||
|
'boattype':'1x',
|
||||||
|
'workouttype': 'rower',
|
||||||
|
}
|
||||||
body = cleanbody(body)
|
body = cleanbody(body)
|
||||||
try:
|
try:
|
||||||
yml = (yaml.safe_load(body))
|
yml = (yaml.safe_load(body))
|
||||||
|
|||||||
@@ -4493,9 +4493,15 @@ def workout_upload_api(request):
|
|||||||
notes=notes,
|
notes=notes,
|
||||||
)
|
)
|
||||||
|
|
||||||
if id <= 0:
|
if id == 0:
|
||||||
message = {'status':'false','message':'unable to process file'+message}
|
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)
|
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)
|
w = Workout.objects.get(id=id)
|
||||||
if len(stravaid)>0:
|
if len(stravaid)>0:
|
||||||
|
|||||||
Reference in New Issue
Block a user