Merge branch 'release/v15.47'
This commit is contained in:
@@ -68,6 +68,8 @@ def process_webhook(notification):
|
|||||||
subscription = notification.subscription
|
subscription = notification.subscription
|
||||||
rs = Rower.objects.filter(subscription_id=subscription.id)
|
rs = Rower.objects.filter(subscription_id=subscription.id)
|
||||||
if rs.count() == 0:
|
if rs.count() == 0:
|
||||||
|
with open('braintreewebhooks.log','a') as f:
|
||||||
|
f.write('Could not find rowers with subscription ID '+subscription.id+'\n')
|
||||||
return 0
|
return 0
|
||||||
r = rs[0]
|
r = rs[0]
|
||||||
result,mesg,errormsg = cancel_subscription(r,subscription.id)
|
result,mesg,errormsg = cancel_subscription(r,subscription.id)
|
||||||
|
|||||||
@@ -1076,7 +1076,6 @@ class CourseSelectForm(forms.Form):
|
|||||||
manager = kwargs.pop('manager',None)
|
manager = kwargs.pop('manager',None)
|
||||||
super(CourseSelectForm,self).__init__(*args,**kwargs)
|
super(CourseSelectForm,self).__init__(*args,**kwargs)
|
||||||
if course is not None:
|
if course is not None:
|
||||||
print('aap',course)
|
|
||||||
d_min = 0.5*course.distance
|
d_min = 0.5*course.distance
|
||||||
d_max = 2*course.distance
|
d_max = 2*course.distance
|
||||||
country = course.country
|
country = course.country
|
||||||
|
|||||||
@@ -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")
|
||||||
|
|||||||
@@ -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]
|
||||||
@@ -1669,26 +1675,14 @@ def workout_getc2workout_all(request,page=1,message=""):
|
|||||||
except NoTokenError:
|
except NoTokenError:
|
||||||
return HttpResponseRedirect("/rowers/me/c2authorize/")
|
return HttpResponseRedirect("/rowers/me/c2authorize/")
|
||||||
|
|
||||||
res = c2stuff.get_c2_workout_list(request.user,page=page)
|
r = getrequestrower(request)
|
||||||
|
|
||||||
if (res.status_code != 200):
|
result = c2stuff.get_c2_workouts(r,do_async=True)
|
||||||
message = "Something went wrong in workout_c2import_view (C2 token refresh)"
|
|
||||||
messages.error(request,message)
|
if result:
|
||||||
|
messages.info(request,'Your C2 workouts will be imported in the coming few minutes')
|
||||||
else:
|
else:
|
||||||
r = getrower(request.user)
|
messages.error(request,'Your C2 workouts import failed')
|
||||||
c2ids = [item['id'] for item in res.json()['data']]
|
|
||||||
alldata = {}
|
|
||||||
for item in res.json()['data']:
|
|
||||||
alldata[item['id']] = item
|
|
||||||
|
|
||||||
knownc2ids = uniqify([
|
|
||||||
w.uploadedtoc2 for w in Workout.objects.filter(user=r)
|
|
||||||
])
|
|
||||||
newids = [c2id for c2id in c2ids if not c2id in knownc2ids]
|
|
||||||
|
|
||||||
for c2id in newids:
|
|
||||||
workoutid = c2stuff.create_async_workout(alldata,
|
|
||||||
request.user,c2id)
|
|
||||||
|
|
||||||
url = reverse('workouts_view')
|
url = reverse('workouts_view')
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
@@ -1718,6 +1712,19 @@ def workout_c2import_view(request,page=1,userid=0,message=""):
|
|||||||
knownc2ids = uniqify([
|
knownc2ids = uniqify([
|
||||||
w.uploadedtoc2 for w in Workout.objects.filter(user=r)
|
w.uploadedtoc2 for w in Workout.objects.filter(user=r)
|
||||||
])
|
])
|
||||||
|
tombstones = [
|
||||||
|
t.uploadedtoc2 for t in TombStone.objects.filter(user=r)
|
||||||
|
]
|
||||||
|
parkedids = []
|
||||||
|
try:
|
||||||
|
with open('c2blocked.json','r') as c2blocked:
|
||||||
|
jsondata = json.load(c2blocked)
|
||||||
|
parkedids = jsondata['ids']
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
knownc2ids = uniqify(knownc2ids+tombstones+parkedids)
|
||||||
|
|
||||||
newids = [c2id for c2id in c2ids if not c2id in knownc2ids]
|
newids = [c2id for c2id in c2ids if not c2id in knownc2ids]
|
||||||
for item in res.json()['data']:
|
for item in res.json()['data']:
|
||||||
d = item['distance']
|
d = item['distance']
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ from rowers.models import (
|
|||||||
PlannedSessionComment,CoachRequest,CoachOffer,
|
PlannedSessionComment,CoachRequest,CoachOffer,
|
||||||
VideoAnalysis,ShareKey,
|
VideoAnalysis,ShareKey,
|
||||||
StandardCollection,CourseStandard,
|
StandardCollection,CourseStandard,
|
||||||
VirtualRaceFollower,
|
VirtualRaceFollower,TombStone
|
||||||
)
|
)
|
||||||
from rowers.models import (
|
from rowers.models import (
|
||||||
RowerPowerForm,RowerHRZonesForm,RowerForm,RowerCPForm,GraphImage,AdvancedWorkoutForm,
|
RowerPowerForm,RowerHRZonesForm,RowerForm,RowerCPForm,GraphImage,AdvancedWorkoutForm,
|
||||||
|
|||||||
Reference in New Issue
Block a user