email processing working on develop
This commit is contained in:
@@ -13,6 +13,7 @@ from django.core.management.base import BaseCommand, CommandError
|
||||
from django.conf import settings
|
||||
#from rowers.mailprocessing import processattachments
|
||||
import time
|
||||
from time import strftime
|
||||
from django.conf import settings
|
||||
from rowers.tasks import handle_sendemail_unrecognized
|
||||
from django_mailbox.models import Mailbox,Message,MessageAttachment
|
||||
@@ -51,7 +52,7 @@ class Command(BaseCommand):
|
||||
extension = a.document.name[-3:].lower()
|
||||
donotdelete = 0
|
||||
m = Message.objects.get(id=a.message_id)
|
||||
body = m.text
|
||||
body = "\n".join(m.text.splitlines())
|
||||
uploadoptions = uploads.upload_options(body)
|
||||
from_address = m.from_address[0].lower()
|
||||
name = m.subject
|
||||
@@ -73,15 +74,19 @@ class Command(BaseCommand):
|
||||
res += wid
|
||||
link = 'http://rowsandall.com/rowers/workout/'+str(wid[0])+'/edit'
|
||||
if uploadoptions and not 'error' in uploadoptions:
|
||||
w = Workout.objects.get(wid[0])
|
||||
w = Workout.objects.get(id=wid[0])
|
||||
r = w.user
|
||||
uploads.do_sync(w,uploadoptions)
|
||||
uploads.make_private(w,uploadoptions)
|
||||
if 'make_plot' in uploadoptions:
|
||||
plottype = uploadoptions['plottype']
|
||||
res = uploads.make_plot(r,w,f2[6:],
|
||||
w.csvfilename,
|
||||
plottype,title)
|
||||
f1 = w.csvfilename[6:-4]
|
||||
timestr = strftime("%Y%m%d-%H%M%S")
|
||||
imagename = f1+timestr+'.png'
|
||||
resu = uploads.make_plot(r,w,f1,
|
||||
w.csvfilename,
|
||||
plottype,name,
|
||||
imagename=imagename)
|
||||
try:
|
||||
if wid != 1:
|
||||
dd = send_confirm(rr.user,title,link,
|
||||
@@ -107,16 +112,19 @@ class Command(BaseCommand):
|
||||
res += wid
|
||||
link = 'http://rowsandall.com/rowers/workout/'+str(wid[0])+'/edit'
|
||||
if uploadoptions:
|
||||
w = Workout.objects.get(wid[0])
|
||||
w = Workout.objects.get(id=wid[0])
|
||||
r = w.user
|
||||
uploads.do_sync(w,uploadoptions)
|
||||
uploads.make_private(w,uploadoptions)
|
||||
if 'make_plot' in uploadoptions:
|
||||
plottype = uploadoptions['plottype']
|
||||
res = uploads.make_plot(r,w,a.document,
|
||||
w.csvfilename,
|
||||
plottype,name)
|
||||
|
||||
f1 = w.csvfilename[6:-4]
|
||||
timestr = strftime("%Y%m%d-%H%M%S")
|
||||
imagename = f1+timestr+'.png'
|
||||
resu = uploads.make_plot(r,w,f1,
|
||||
w.csvfilename,
|
||||
plottype,name,
|
||||
imagename=imagename)
|
||||
|
||||
except:
|
||||
# replace with code to process error
|
||||
@@ -131,7 +139,7 @@ class Command(BaseCommand):
|
||||
except:
|
||||
pass
|
||||
|
||||
# remove attachment
|
||||
# remove attachment
|
||||
if donotdelete == 0:
|
||||
a.delete()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user