Private
Public Access
1
0

bug fixes

This commit is contained in:
Sander Roosendaal
2020-02-18 21:37:13 +01:00
parent fc6dd7e347
commit 38094d7b13
6 changed files with 35 additions and 33 deletions

View File

@@ -83,6 +83,8 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
users = User.objects.filter(username=uploadoptions['username'])
if len(users)==1:
therower = users[0].rower
elif uploadoptions['username'] == '':
therower = rower
else:
return 0
else:
@@ -94,7 +96,6 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
uploadoptions['file'] = 'media/'+filename
uploadoptions['title'] = title
url = settings.UPLOAD_SERVICE_URL
if not testing:
response = requests.post(url,data=uploadoptions)
@@ -239,24 +240,19 @@ class Command(BaseCommand):
attachment.delete()
for rower in rowers:
if 'zip' in extension:
try:
zip_file = zipfile.ZipFile(attachment.document)
for id,filename in enumerate(zip_file.namelist()):
datafile = zip_file.extract(
filename, path='media/')
if id>0:
title = name+' ('+str(id+1)+')'
else:
title = name
zip_file = zipfile.ZipFile(attachment.document)
for id,filename in enumerate(zip_file.namelist()):
datafile = zip_file.extract(
filename, path='media/')
if id>0:
title = name+' ('+str(id+1)+')'
else:
title = name
workoutid = processattachment(
rower, datafile, title, uploadoptions,
testing=testing
)
workoutid = processattachment(
rower, datafile, title, uploadoptions,
testing=testing
)
print(workoutid)
except:
print("Bad ZIP file")
print(attachment.document.name)
else:
# move attachment and make workout
if testing: