email zip processing improved
This commit is contained in:
@@ -1 +0,0 @@
|
|||||||
E408191@CZ27LT9RCGN72.13020:1492098105
|
|
||||||
@@ -573,26 +573,20 @@ def new_workout_from_file(r,f2,
|
|||||||
inboard = 0.88
|
inboard = 0.88
|
||||||
if len(fileformat)==3 and fileformat[0]=='zip':
|
if len(fileformat)==3 and fileformat[0]=='zip':
|
||||||
f_to_be_deleted = f2
|
f_to_be_deleted = f2
|
||||||
with zipfile.ZipFile(f2) as z:
|
title = os.path.basename(f2)
|
||||||
for fname in z.namelist():
|
if settings.DEBUG:
|
||||||
f3 = z.extract(fname,path='media/')
|
res = handle_zip_file.delay(
|
||||||
print f3,r.user.email,title
|
r.user.email,title,f2
|
||||||
if settings.DEBUG:
|
)
|
||||||
res = handle_zip_file.delay(
|
|
||||||
r.user.email,title,f3
|
|
||||||
)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
res = queuelow.enqueue(
|
res = queuelow.enqueue(
|
||||||
handle_zip_file,
|
handle_zip_file,
|
||||||
r.user.email,
|
r.user.email,
|
||||||
title,
|
title,
|
||||||
f3
|
f2
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
os.remove(f_to_be_deleted)
|
|
||||||
return -1,message,f2
|
return -1,message,f2
|
||||||
|
|
||||||
# Some people try to upload Concept2 logbook summaries
|
# Some people try to upload Concept2 logbook summaries
|
||||||
|
|||||||
@@ -63,12 +63,14 @@ class Command(BaseCommand):
|
|||||||
z = zipfile.ZipFile(a.document)
|
z = zipfile.ZipFile(a.document)
|
||||||
for f in z.namelist():
|
for f in z.namelist():
|
||||||
f2 = z.extract(f,path='media/')
|
f2 = z.extract(f,path='media/')
|
||||||
|
title = os.path.basename(f2)
|
||||||
wid = [
|
wid = [
|
||||||
make_new_workout_from_email(rr,f2[6:],name)
|
make_new_workout_from_email(rr,f2[6:],title)
|
||||||
]
|
]
|
||||||
res += wid
|
res += wid
|
||||||
link = 'http://rowsandall.com/rowers/workout/'+str(wid[0])+'/edit'
|
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:
|
else:
|
||||||
# move attachment and make workout
|
# move attachment and make workout
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ def handle_zip_file(emailfrom,subject,file):
|
|||||||
['workouts@rowsandall.com'])
|
['workouts@rowsandall.com'])
|
||||||
email.attach_file(file)
|
email.attach_file(file)
|
||||||
res = email.send()
|
res = email.send()
|
||||||
|
time.sleep(60)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
# Send email with CSV attachment
|
# Send email with CSV attachment
|
||||||
|
|||||||
@@ -5231,7 +5231,7 @@ def workout_upload_view(request,message="",
|
|||||||
response = HttpResponseRedirect(url)
|
response = HttpResponseRedirect(url)
|
||||||
return response
|
return response
|
||||||
elif id == -1:
|
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,
|
url = reverse(workout_upload_view,
|
||||||
args=[str(message)])
|
args=[str(message)])
|
||||||
response = HttpResponseRedirect(url)
|
response = HttpResponseRedirect(url)
|
||||||
|
|||||||
Reference in New Issue
Block a user