Private
Public Access
1
0

email zip processing improved

This commit is contained in:
Sander Roosendaal
2017-04-14 15:12:35 +02:00
parent 5bc69b3a49
commit ef398dcaee
5 changed files with 18 additions and 22 deletions

View File

@@ -1 +0,0 @@
E408191@CZ27LT9RCGN72.13020:1492098105

View File

@@ -573,26 +573,20 @@ def new_workout_from_file(r,f2,
inboard = 0.88
if len(fileformat)==3 and fileformat[0]=='zip':
f_to_be_deleted = f2
with zipfile.ZipFile(f2) as z:
for fname in z.namelist():
f3 = z.extract(fname,path='media/')
print f3,r.user.email,title
if settings.DEBUG:
res = handle_zip_file.delay(
r.user.email,title,f3
)
title = os.path.basename(f2)
if settings.DEBUG:
res = handle_zip_file.delay(
r.user.email,title,f2
)
else:
res = queuelow.enqueue(
handle_zip_file,
r.user.email,
title,
f3
)
else:
res = queuelow.enqueue(
handle_zip_file,
r.user.email,
title,
f2
)
os.remove(f_to_be_deleted)
return -1,message,f2
# Some people try to upload Concept2 logbook summaries

View File

@@ -63,12 +63,14 @@ class Command(BaseCommand):
z = zipfile.ZipFile(a.document)
for f in z.namelist():
f2 = z.extract(f,path='media/')
title = os.path.basename(f2)
wid = [
make_new_workout_from_email(rr,f2[6:],name)
make_new_workout_from_email(rr,f2[6:],title)
]
res += wid
link = 'http://rowsandall.com/rowers/workout/'+str(wid[0])+'/edit'
dd = send_confirm(rr.user,name,link)
dd = send_confirm(rr.user,title,link)
time.sleep(10)
else:
# move attachment and make workout

View File

@@ -98,6 +98,7 @@ def handle_zip_file(emailfrom,subject,file):
['workouts@rowsandall.com'])
email.attach_file(file)
res = email.send()
time.sleep(60)
return 1
# Send email with CSV attachment

View File

@@ -5231,7 +5231,7 @@ def workout_upload_view(request,message="",
response = HttpResponseRedirect(url)
return response
elif id == -1:
message = 'Zip files will be processed in the background'
message = 'The zip archive will be processed in the background. The files in the archive will only be uploaded without the extra actions. You will receive email when the workouts are ready.'
url = reverse(workout_upload_view,
args=[str(message)])
response = HttpResponseRedirect(url)