implemented make_plot
This commit is contained in:
@@ -30,13 +30,15 @@ queuelow = django_rq.get_queue('low')
|
|||||||
queuehigh = django_rq.get_queue('default')
|
queuehigh = django_rq.get_queue('default')
|
||||||
|
|
||||||
# Sends a confirmation with a link to the workout
|
# Sends a confirmation with a link to the workout
|
||||||
def send_confirm(u,name,link):
|
def send_confirm(u,name,link,options):
|
||||||
fullemail = u.email
|
fullemail = u.email
|
||||||
subject = 'Workout added: '+name
|
subject = 'Workout added: '+name
|
||||||
message = 'Dear '+u.first_name+',\n\n'
|
message = 'Dear '+u.first_name+',\n\n'
|
||||||
message += "Your workout has been added to Rowsandall.com.\n"
|
message += "Your workout has been added to Rowsandall.com.\n"
|
||||||
message += "Link to workout: "+link+"\n\n"
|
message += "Link to workout: "+link+"\n\n"
|
||||||
message += "Best Regards, the Rowsandall Team"
|
message += "Best Regards, the Rowsandall Team"
|
||||||
|
if options:
|
||||||
|
message += "\n\n"+options
|
||||||
|
|
||||||
email = EmailMessage(subject,message,
|
email = EmailMessage(subject,message,
|
||||||
'Rowsandall <info@rowsandall.com>',
|
'Rowsandall <info@rowsandall.com>',
|
||||||
|
|||||||
@@ -72,15 +72,24 @@ class Command(BaseCommand):
|
|||||||
]
|
]
|
||||||
res += wid
|
res += wid
|
||||||
link = 'http://rowsandall.com/rowers/workout/'+str(wid[0])+'/edit'
|
link = 'http://rowsandall.com/rowers/workout/'+str(wid[0])+'/edit'
|
||||||
|
if uploadoptions and not 'error' in uploadoptions:
|
||||||
|
w = Workout.objects.get(wid[0])
|
||||||
|
r = w.user
|
||||||
|
if 'make_plot' in uploadoptions:
|
||||||
|
plottype = uploadoptions['plottype']
|
||||||
|
res = uploads.make_plot(r,w,plottype,
|
||||||
|
title,f2[6:],f2)
|
||||||
try:
|
try:
|
||||||
if wid != 1:
|
if wid != 1:
|
||||||
dd = send_confirm(rr.user,title,link)
|
dd = send_confirm(rr.user,title,link,
|
||||||
|
uploadoptions)
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
except:
|
except:
|
||||||
try:
|
try:
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
if wid != 1:
|
if wid != 1:
|
||||||
dd = send_confirm(rr.user,title,link)
|
dd = send_confirm(rr.user,title,link,
|
||||||
|
uploadoptions)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -94,7 +103,14 @@ class Command(BaseCommand):
|
|||||||
]
|
]
|
||||||
res += wid
|
res += wid
|
||||||
link = 'http://rowsandall.com/rowers/workout/'+str(wid[0])+'/edit'
|
link = 'http://rowsandall.com/rowers/workout/'+str(wid[0])+'/edit'
|
||||||
|
if uploadoptions:
|
||||||
|
w = Workout.objects.get(wid[0])
|
||||||
|
r = w.user
|
||||||
|
if 'make_plot' in uploadoptions:
|
||||||
|
plottype = uploadoptions['plottype']
|
||||||
|
res = uploads.make_plot(r,w,plottype,
|
||||||
|
title,f2[6:],f2)
|
||||||
|
|
||||||
except:
|
except:
|
||||||
# replace with code to process error
|
# replace with code to process error
|
||||||
res += ['fail: '+name]
|
res += ['fail: '+name]
|
||||||
@@ -102,7 +118,8 @@ class Command(BaseCommand):
|
|||||||
wid = 1
|
wid = 1
|
||||||
try:
|
try:
|
||||||
if wid != 1:
|
if wid != 1:
|
||||||
dd = send_confirm(rr.user,name,link)
|
dd = send_confirm(rr.user,name,link,
|
||||||
|
uploadoptions)
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -83,16 +83,32 @@ def getplotoptions(uploadoptions,value):
|
|||||||
|
|
||||||
return uploadoptions
|
return uploadoptions
|
||||||
|
|
||||||
|
def getboolean(uploadoptions,value,key):
|
||||||
|
b = True
|
||||||
|
if not value:
|
||||||
|
b = False
|
||||||
|
if value in [False,'false','False',None,'no']:
|
||||||
|
b = False
|
||||||
|
|
||||||
|
uploadoptions[key] = b
|
||||||
|
|
||||||
|
return uploadoptions
|
||||||
|
|
||||||
def upload_options(body):
|
def upload_options(body):
|
||||||
uploadoptions = {}
|
uploadoptions = {}
|
||||||
body = cleanbody(body)
|
body = cleanbody(body)
|
||||||
try:
|
try:
|
||||||
yml = (yaml.load(body))
|
yml = (yaml.load(body))
|
||||||
for key, value in yml.iteritems():
|
try:
|
||||||
if key == 'sync' or key == 'synchronization':
|
for key, value in yml.iteritems():
|
||||||
uploadoptions = getsyncoptions(uploadoptions,value)
|
if key == 'sync' or key == 'synchronization':
|
||||||
if key == 'chart' or key == 'static' or key == 'plot':
|
uploadoptions = getsyncoptions(uploadoptions,value)
|
||||||
uploadoptions = getplotoptions(uploadoptions,value)
|
if key == 'chart' or key == 'static' or key == 'plot':
|
||||||
|
uploadoptions = getplotoptions(uploadoptions,value)
|
||||||
|
if 'priva' in key:
|
||||||
|
uploadoptions = getboolean(uploadoptions,value,'makeprivate')
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
except yaml.YAMLError as exc:
|
except yaml.YAMLError as exc:
|
||||||
pm = exc.problem_mark
|
pm = exc.problem_mark
|
||||||
strpm = str(pm)
|
strpm = str(pm)
|
||||||
|
|||||||
Reference in New Issue
Block a user