bug fixes
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user