add match option to stravaexportas
This commit is contained in:
@@ -748,6 +748,7 @@ class CoachingGroup(models.Model):
|
|||||||
class Rower(models.Model):
|
class Rower(models.Model):
|
||||||
adaptivetypes = mytypes.adaptivetypes
|
adaptivetypes = mytypes.adaptivetypes
|
||||||
stravatypes = (
|
stravatypes = (
|
||||||
|
('match','Variable - try to match the type'),
|
||||||
('Ride','Ride'),
|
('Ride','Ride'),
|
||||||
('Kitesurf','Kitesurf'),
|
('Kitesurf','Kitesurf'),
|
||||||
('Run','Run'),
|
('Run','Run'),
|
||||||
@@ -965,7 +966,7 @@ class Rower(models.Model):
|
|||||||
stravatokenexpirydate = models.DateTimeField(blank=True,null=True)
|
stravatokenexpirydate = models.DateTimeField(blank=True,null=True)
|
||||||
stravarefreshtoken = models.CharField(default='',max_length=1000,
|
stravarefreshtoken = models.CharField(default='',max_length=1000,
|
||||||
blank=True,null=True)
|
blank=True,null=True)
|
||||||
stravaexportas = models.CharField(default="Rowing",
|
stravaexportas = models.CharField(default="match",
|
||||||
max_length=30,
|
max_length=30,
|
||||||
choices=stravatypes,
|
choices=stravatypes,
|
||||||
verbose_name="Export Workouts to Strava as")
|
verbose_name="Export Workouts to Strava as")
|
||||||
@@ -2292,7 +2293,7 @@ class PlannedSession(models.Model):
|
|||||||
if self.sessionvalue <= 0:
|
if self.sessionvalue <= 0:
|
||||||
self.sessionvalue = 1
|
self.sessionvalue = 1
|
||||||
|
|
||||||
|
|
||||||
manager = self.manager
|
manager = self.manager
|
||||||
if self.sessiontype not in ['race','indoorrace']:
|
if self.sessiontype not in ['race','indoorrace']:
|
||||||
if not can_add_session(self.manager):
|
if not can_add_session(self.manager):
|
||||||
|
|||||||
@@ -752,23 +752,36 @@ def workout_strava_upload(user,w, quick=False,asynchron=True):
|
|||||||
tcxfile, tcxmesg = createstravaworkoutdata(w)
|
tcxfile, tcxmesg = createstravaworkoutdata(w)
|
||||||
if not tcxfile:
|
if not tcxfile:
|
||||||
return "Failed to create workout data",0
|
return "Failed to create workout data",0
|
||||||
|
activity_type = r.stravaexportas
|
||||||
|
if r.stravaexportas == 'match':
|
||||||
|
try:
|
||||||
|
activity_type = mytypes.stravamapping[w.workouttype]
|
||||||
|
except KeyError:
|
||||||
|
activity_type = 'Rowing'
|
||||||
job = myqueue(queue,
|
job = myqueue(queue,
|
||||||
handle_strava_sync,
|
handle_strava_sync,
|
||||||
r.stravatoken,
|
r.stravatoken,
|
||||||
w.id,
|
w.id,
|
||||||
tcxfile,w.name,r.stravaexportas,
|
tcxfile,w.name,activity_type,
|
||||||
w.notes
|
w.notes
|
||||||
)
|
)
|
||||||
return "Asynchronous sync",-1
|
return "Asynchronous sync",-1
|
||||||
try:
|
try:
|
||||||
tcxfile,tcxmesg = createstravaworkoutdata(w)
|
tcxfile,tcxmesg = createstravaworkoutdata(w)
|
||||||
if tcxfile:
|
if tcxfile:
|
||||||
|
activity_type = r.stravaexportas
|
||||||
|
if r.stravaexportas == 'match':
|
||||||
|
try:
|
||||||
|
activity_type = mytypes.stravamapping[w.workouttype]
|
||||||
|
except KeyError:
|
||||||
|
activity_type = 'Rowing'
|
||||||
|
print(w.workouttype,activity_type)
|
||||||
with open(tcxfile,'rb') as f:
|
with open(tcxfile,'rb') as f:
|
||||||
res,mes = handle_stravaexport(
|
res,mes = handle_stravaexport(
|
||||||
f,w.name,
|
f,w.name,
|
||||||
r.stravatoken,
|
r.stravatoken,
|
||||||
description=w.notes+'\n from '+w.workoutsource+' via rowsandall.com',
|
description=w.notes+'\n from '+w.workoutsource+' via rowsandall.com',
|
||||||
activity_type=r.stravaexportas,quick=quick,asynchron=asynchron)
|
activity_type=activity_type,quick=quick,asynchron=asynchron)
|
||||||
if res==0:
|
if res==0:
|
||||||
message = mes
|
message = mes
|
||||||
w.uploadedtostrava = -1
|
w.uploadedtostrava = -1
|
||||||
|
|||||||
@@ -93,8 +93,14 @@ def workout_strava_upload_view(request,id=0):
|
|||||||
newnotes = w.notes+'\n from '+w.workoutsource+' via rowsandall.com'
|
newnotes = w.notes+'\n from '+w.workoutsource+' via rowsandall.com'
|
||||||
except TypeError:
|
except TypeError:
|
||||||
newnotes = 'from '+w.workoutsource+' via rowsandall.com'
|
newnotes = 'from '+w.workoutsource+' via rowsandall.com'
|
||||||
|
activity_type = 'Ride'
|
||||||
if w.workouttype in mytypes.rowtypes:
|
if w.workouttype in mytypes.rowtypes:
|
||||||
activity_type = r.stravaexportas
|
activity_type = r.stravaexportas
|
||||||
|
if activity_type == 'match':
|
||||||
|
try:
|
||||||
|
activity_type = mytypes.stravamapping[w.workouttype]
|
||||||
|
except KeyError:
|
||||||
|
activity_type = 'Ride'
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
activity_type = mytypes.stravamapping[w.workouttype]
|
activity_type = mytypes.stravamapping[w.workouttype]
|
||||||
|
|||||||
Reference in New Issue
Block a user