add workouttype & boattype to email processing
This commit is contained in:
@@ -72,6 +72,7 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
|
|||||||
workout = Workout.objects.get(id=workoutid[0])
|
workout = Workout.objects.get(id=workoutid[0])
|
||||||
uploads.do_sync(workout, uploadoptions)
|
uploads.do_sync(workout, uploadoptions)
|
||||||
uploads.make_private(workout, uploadoptions)
|
uploads.make_private(workout, uploadoptions)
|
||||||
|
uploads.set_workouttype(workout, uploadoptions)
|
||||||
if 'make_plot' in uploadoptions:
|
if 'make_plot' in uploadoptions:
|
||||||
plottype = uploadoptions['plottype']
|
plottype = uploadoptions['plottype']
|
||||||
workoutcsvfilename = workout.csvfilename[6:-4]
|
workoutcsvfilename = workout.csvfilename[6:-4]
|
||||||
|
|||||||
@@ -362,7 +362,11 @@ class EmailTests(TestCase):
|
|||||||
from_header = u.email,
|
from_header = u.email,
|
||||||
subject = filename,
|
subject = filename,
|
||||||
body="""
|
body="""
|
||||||
chart time
|
---
|
||||||
|
chart: time
|
||||||
|
workouttype: water
|
||||||
|
boattype: 4x
|
||||||
|
...
|
||||||
""")
|
""")
|
||||||
m.save()
|
m.save()
|
||||||
a2 = 'media/mailbox_attachments/'+filename
|
a2 = 'media/mailbox_attachments/'+filename
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ queue = django_rq.get_queue('default')
|
|||||||
queuelow = django_rq.get_queue('low')
|
queuelow = django_rq.get_queue('low')
|
||||||
queuehigh = django_rq.get_queue('low')
|
queuehigh = django_rq.get_queue('low')
|
||||||
|
|
||||||
|
from types import workouttypes,boattypes
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
except:
|
except:
|
||||||
@@ -96,6 +98,29 @@ def matchsync(line):
|
|||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
def gettypeoptions_body2(uploadoptions,body):
|
||||||
|
tester = re.compile('^(workout)')
|
||||||
|
testerb = re.compile('^(boat)')
|
||||||
|
for line in body.splitlines():
|
||||||
|
if tester.match(line.lower()):
|
||||||
|
for typ,verb in workouttypes:
|
||||||
|
str1 = '^(workout)(.*)({a})'.format(
|
||||||
|
a = typ
|
||||||
|
)
|
||||||
|
testert = re.compile(str1)
|
||||||
|
if testert.match(line.lower()):
|
||||||
|
uploadoptions['workouttype'] = typ
|
||||||
|
if testerb.match(line.lower()):
|
||||||
|
for typ,verb in boattypes:
|
||||||
|
str1 = '^(boat)(.*)({a})'.format(
|
||||||
|
a = typ
|
||||||
|
)
|
||||||
|
testert = re.compile(str1)
|
||||||
|
if testert.match(line.lower()):
|
||||||
|
uploadoptions['boattype'] = typ
|
||||||
|
|
||||||
|
return uploadoptions
|
||||||
|
|
||||||
def getprivateoptions_body2(uploadoptions,body):
|
def getprivateoptions_body2(uploadoptions,body):
|
||||||
tester = re.compile('^(priva)')
|
tester = re.compile('^(priva)')
|
||||||
for line in body.splitlines():
|
for line in body.splitlines():
|
||||||
@@ -181,7 +206,6 @@ def getplotoptions(uploadoptions,value):
|
|||||||
|
|
||||||
return uploadoptions
|
return uploadoptions
|
||||||
|
|
||||||
from types import workouttypes,boattypes
|
|
||||||
|
|
||||||
def gettype(uploadoptions,value,key):
|
def gettype(uploadoptions,value,key):
|
||||||
workouttype = 'rower'
|
workouttype = 'rower'
|
||||||
@@ -235,10 +259,10 @@ def upload_options(body):
|
|||||||
uploadoptions = getplotoptions(uploadoptions,value)
|
uploadoptions = getplotoptions(uploadoptions,value)
|
||||||
if 'priva' in lowkey:
|
if 'priva' in lowkey:
|
||||||
uploadoptions = getboolean(uploadoptions,value,'makeprivate')
|
uploadoptions = getboolean(uploadoptions,value,'makeprivate')
|
||||||
if 'type' in lowkey:
|
if 'workout' in lowkey:
|
||||||
uploadoptions = gettype(uploadoptions,value,'workouttype')
|
uploadoptions = gettype(uploadoptions,value,'workouttype')
|
||||||
if 'boat' in lowkey:
|
if 'boat' in lowkey:
|
||||||
uploadoptions = getboattype(uploadoptions,value,'workouttype')
|
uploadoptions = getboattype(uploadoptions,value,'boattype')
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
#pass
|
#pass
|
||||||
raise yaml.YAMLError
|
raise yaml.YAMLError
|
||||||
@@ -247,6 +271,7 @@ def upload_options(body):
|
|||||||
uploadoptions = getplotoptions_body2(uploadoptions,body)
|
uploadoptions = getplotoptions_body2(uploadoptions,body)
|
||||||
uploadoptions = getsyncoptions_body2(uploadoptions,body)
|
uploadoptions = getsyncoptions_body2(uploadoptions,body)
|
||||||
uploadoptions = getprivateoptions_body2(uploadoptions,body)
|
uploadoptions = getprivateoptions_body2(uploadoptions,body)
|
||||||
|
typeoptions = gettypeoptions_body2(uploadoptions,body)
|
||||||
except IOError:
|
except IOError:
|
||||||
pm = exc.problem_mark
|
pm = exc.problem_mark
|
||||||
strpm = str(pm)
|
strpm = str(pm)
|
||||||
@@ -327,6 +352,20 @@ def make_plot(r,w,f1,f2,plottype,title,imagename='',plotnr=0):
|
|||||||
import c2stuff,stravastuff,sporttracksstuff,runkeeperstuff
|
import c2stuff,stravastuff,sporttracksstuff,runkeeperstuff
|
||||||
import underarmourstuff,tpstuff
|
import underarmourstuff,tpstuff
|
||||||
|
|
||||||
|
def set_workouttype(w,options):
|
||||||
|
try:
|
||||||
|
w.workouttype = options['workouttype']
|
||||||
|
w.save()
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
w.boattype = options['boattype']
|
||||||
|
w.save()
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return 1
|
||||||
|
|
||||||
def make_private(w,options):
|
def make_private(w,options):
|
||||||
if 'makeprivate' in options and options['makeprivate']:
|
if 'makeprivate' in options and options['makeprivate']:
|
||||||
w.privacy = 'hidden'
|
w.privacy = 'hidden'
|
||||||
|
|||||||
Reference in New Issue
Block a user