through emails now
This commit is contained in:
@@ -119,28 +119,6 @@ def get_strava_workout_list(user):
|
|||||||
|
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def add_stroke_data(user,stravaid,workoutid,startdatetime,csvfilename,debug=False):
|
|
||||||
r = Rower.objects.get(user=user)
|
|
||||||
|
|
||||||
starttimeunix = arrow.get(startdatetime).timestamp
|
|
||||||
|
|
||||||
if not debug:
|
|
||||||
job = myqueue(queue,
|
|
||||||
handle_strava_import_stroke_data,
|
|
||||||
r.stravatoken,
|
|
||||||
stravaid,
|
|
||||||
workoutid,
|
|
||||||
starttimeunix,
|
|
||||||
csvfilename)
|
|
||||||
else:
|
|
||||||
handle_strava_import_stroke_data(
|
|
||||||
r.stravatoken,
|
|
||||||
stravaid,
|
|
||||||
workoutid,
|
|
||||||
starttimeunix,
|
|
||||||
csvfilename,
|
|
||||||
debug=debug
|
|
||||||
)
|
|
||||||
|
|
||||||
# gets all new Strava workouts for a rower
|
# gets all new Strava workouts for a rower
|
||||||
def get_strava_workouts(rower):
|
def get_strava_workouts(rower):
|
||||||
|
|||||||
@@ -207,20 +207,23 @@ def handle_strava_import_stroke_data(title,
|
|||||||
|
|
||||||
df.sort_values(by='TimeStamp (sec)',ascending=True)
|
df.sort_values(by='TimeStamp (sec)',ascending=True)
|
||||||
|
|
||||||
res = df.to_csv(csvfilename+'.gz',index_label='index',compression='gzip')
|
res = df.to_csv(csvfilename,index_label='index')
|
||||||
|
|
||||||
d = {
|
d = {
|
||||||
'some_attribute':1
|
'stravaid':stravaid
|
||||||
}
|
}
|
||||||
|
|
||||||
res = send_template_email(useremail,[workoutemailbox],
|
res = send_template_email(useremail,[workoutemailbox],
|
||||||
title,'workoutemail.html',
|
title,'workoutemail.html',
|
||||||
d,
|
d,
|
||||||
attach_file=csvfilename+'.gz')
|
attach_file=csvfilename)
|
||||||
|
|
||||||
os.remove(csvfilename+'.gz')
|
|
||||||
|
|
||||||
return 1
|
time.sleep(1)
|
||||||
|
|
||||||
|
os.remove(csvfilename)
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
@app.task
|
@app.task
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{% extends "emailbase.html" %}
|
{% extends "emailbase.html" %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
|
stravaid {{ stravaid }}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
@@ -98,6 +98,17 @@ def matchsync(line):
|
|||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
def getstravaid(uploadoptions,body):
|
||||||
|
stravaid = 0
|
||||||
|
tester = re.compile('^(stravaid)(.*?)(\d+)')
|
||||||
|
for line in body.splitlines():
|
||||||
|
if tester.match(line.lower()):
|
||||||
|
stravaid = tester.match(line.lower()).group(3)
|
||||||
|
|
||||||
|
uploadoptions['stravaid'] = int(stravaid)
|
||||||
|
|
||||||
|
return uploadoptions
|
||||||
|
|
||||||
def gettypeoptions_body2(uploadoptions,body):
|
def gettypeoptions_body2(uploadoptions,body):
|
||||||
tester = re.compile('^(workout)')
|
tester = re.compile('^(workout)')
|
||||||
testerb = re.compile('^(boat)')
|
testerb = re.compile('^(boat)')
|
||||||
@@ -272,6 +283,7 @@ def upload_options(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)
|
typeoptions = gettypeoptions_body2(uploadoptions,body)
|
||||||
|
uploadoptions = getstravaid(uploadoptions,body)
|
||||||
except IOError:
|
except IOError:
|
||||||
pm = exc.problem_mark
|
pm = exc.problem_mark
|
||||||
strpm = str(pm)
|
strpm = str(pm)
|
||||||
@@ -376,6 +388,13 @@ def make_private(w,options):
|
|||||||
from rowers.utils import isprorower
|
from rowers.utils import isprorower
|
||||||
|
|
||||||
def do_sync(w,options):
|
def do_sync(w,options):
|
||||||
|
try:
|
||||||
|
if options['stravaid'] != 0:
|
||||||
|
w.uploadedtostrava = stravaid
|
||||||
|
w.save()
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
if ('upload_to_C2' in options and options['upload_to_C2']) or (w.user.c2_auto_export and isprorower(w.user)):
|
if ('upload_to_C2' in options and options['upload_to_C2']) or (w.user.c2_auto_export and isprorower(w.user)):
|
||||||
try:
|
try:
|
||||||
message,id = c2stuff.workout_c2_upload(w.user.user,w)
|
message,id = c2stuff.workout_c2_upload(w.user.user,w)
|
||||||
|
|||||||
Reference in New Issue
Block a user