Private
Public Access
1
0

implemented make_plot

This commit is contained in:
Sander Roosendaal
2017-09-26 12:57:00 +02:00
parent 4ec43770db
commit d56a8bb74d
3 changed files with 45 additions and 10 deletions

View File

@@ -30,13 +30,15 @@ queuelow = django_rq.get_queue('low')
queuehigh = django_rq.get_queue('default')
# 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
subject = 'Workout added: '+name
message = 'Dear '+u.first_name+',\n\n'
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
email = EmailMessage(subject,message,
'Rowsandall <info@rowsandall.com>',

View File

@@ -72,15 +72,24 @@ 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])
r = w.user
if 'make_plot' in uploadoptions:
plottype = uploadoptions['plottype']
res = uploads.make_plot(r,w,plottype,
title,f2[6:],f2)
try:
if wid != 1:
dd = send_confirm(rr.user,title,link)
dd = send_confirm(rr.user,title,link,
uploadoptions)
time.sleep(10)
except:
try:
time.sleep(10)
if wid != 1:
dd = send_confirm(rr.user,title,link)
dd = send_confirm(rr.user,title,link,
uploadoptions)
except:
pass
@@ -94,7 +103,14 @@ class Command(BaseCommand):
]
res += wid
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:
# replace with code to process error
res += ['fail: '+name]
@@ -102,7 +118,8 @@ class Command(BaseCommand):
wid = 1
try:
if wid != 1:
dd = send_confirm(rr.user,name,link)
dd = send_confirm(rr.user,name,link,
uploadoptions)
time.sleep(10)
except:
pass

View File

@@ -83,16 +83,32 @@ def getplotoptions(uploadoptions,value):
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):
uploadoptions = {}
body = cleanbody(body)
try:
yml = (yaml.load(body))
for key, value in yml.iteritems():
if key == 'sync' or key == 'synchronization':
uploadoptions = getsyncoptions(uploadoptions,value)
if key == 'chart' or key == 'static' or key == 'plot':
uploadoptions = getplotoptions(uploadoptions,value)
try:
for key, value in yml.iteritems():
if key == 'sync' or key == 'synchronization':
uploadoptions = getsyncoptions(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:
pm = exc.problem_mark
strpm = str(pm)