email processing working on develop
This commit is contained in:
@@ -37,8 +37,10 @@ def send_confirm(u,name,link,options):
|
||||
message += "Your workout has been added to Rowsandall.com.\n"
|
||||
message += "Link to workout: "+link+"\n\n"
|
||||
message += "Best Regards, the Rowsandall Team"
|
||||
|
||||
if options:
|
||||
message += "\n\n"+options
|
||||
message += "\n\n"+str(options)
|
||||
|
||||
|
||||
email = EmailMessage(subject,message,
|
||||
'Rowsandall <info@rowsandall.com>',
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -28,10 +28,13 @@ from rowers.utils import (
|
||||
)
|
||||
|
||||
def cleanbody(body):
|
||||
p = re.compile('.*---\n([\s\S]*)...')
|
||||
m = p.match(body)
|
||||
if m != None:
|
||||
body = m.group(1)
|
||||
regex = r".*---\n([\s\S]*?)\.\.\..*"
|
||||
matches = re.finditer(regex,body)
|
||||
|
||||
for m in matches:
|
||||
|
||||
if m != None:
|
||||
body = m.group(0)
|
||||
|
||||
return body
|
||||
|
||||
@@ -191,7 +194,7 @@ def do_sync(w,options):
|
||||
if 'upload_to_C2' in options and options['upload_to_C2']:
|
||||
try:
|
||||
message,id = c2stuff.workout_c2_upload(w.user.user,w)
|
||||
except C2NoTokenError:
|
||||
except c2stuff.C2NoTokenError:
|
||||
id = 0
|
||||
message = "Something went wrong with the Concept2 sync"
|
||||
|
||||
@@ -200,7 +203,7 @@ def do_sync(w,options):
|
||||
message,id = stravastuff.workout_strava_upload(
|
||||
w.user.user,w
|
||||
)
|
||||
except StravaNoTokenError:
|
||||
except stravastuff.StravaNoTokenError:
|
||||
id = 0
|
||||
message = "Please connect to Strava first"
|
||||
|
||||
@@ -210,7 +213,7 @@ def do_sync(w,options):
|
||||
message,id = sporttracksstuff.workout_sporttracks_upload(
|
||||
w.user.user,w
|
||||
)
|
||||
except SportTracksNoTokenError:
|
||||
except sporttracksstuff.SportTracksNoTokenError:
|
||||
message = "Please connect to SportTracks first"
|
||||
id = 0
|
||||
|
||||
@@ -220,7 +223,7 @@ def do_sync(w,options):
|
||||
message,id = runkeeperstuff.workout_runkeeper_upload(
|
||||
w.user.user,w
|
||||
)
|
||||
except RunKeeperNoTokenError:
|
||||
except runkeeperstuff.RunKeeperNoTokenError:
|
||||
message = "Please connect to Runkeeper first"
|
||||
id = 0
|
||||
|
||||
@@ -229,7 +232,7 @@ def do_sync(w,options):
|
||||
message,id = underarmourstuff.workout_ua_upload(
|
||||
w.user.user,w
|
||||
)
|
||||
except UnderArmourNoTokenError:
|
||||
except underarmourstuff.UnderArmourNoTokenError:
|
||||
message = "Please connect to MapMyFitness first"
|
||||
id = 0
|
||||
|
||||
@@ -239,7 +242,7 @@ def do_sync(w,options):
|
||||
message,id = tpstuff.workout_tp_upload(
|
||||
w.user.user,w
|
||||
)
|
||||
except TPNoTokenError:
|
||||
except tpstuff.TPNoTokenError:
|
||||
message = "Please connect to TrainingPeaks first"
|
||||
id = 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user