code merge strava import all
This commit is contained in:
@@ -9694,35 +9694,10 @@ def workout_getsporttracksworkout_all(request):
|
|||||||
# Imports all new workouts from SportTracks
|
# Imports all new workouts from SportTracks
|
||||||
@login_required()
|
@login_required()
|
||||||
def workout_getstravaworkout_all(request):
|
def workout_getstravaworkout_all(request):
|
||||||
res = stravastuff.get_strava_workout_list(request.user)
|
|
||||||
if (res.status_code == 200):
|
|
||||||
r = getrower(request.user)
|
r = getrower(request.user)
|
||||||
stravaids = [int(item['id']) for item in res.json()]
|
res = stravastuff.get_strava_workouts(r)
|
||||||
knownstravaids = uniqify([
|
if res == 1:
|
||||||
w.uploadedtostrava for w in Workout.objects.filter(user=r)
|
messages.info(request,"Your workouts are being imported and should appear on the site in the next 15 minutes")
|
||||||
])
|
|
||||||
newids = [stravaid for stravaid in stravaids if not stravaid in knownstravaids]
|
|
||||||
|
|
||||||
for stravaid in newids:
|
|
||||||
res = stravastuff.get_workout(request.user,stravaid)
|
|
||||||
strokedata = res[1]
|
|
||||||
data = res[0]
|
|
||||||
|
|
||||||
if data:
|
|
||||||
id,message = add_workout_from_strokedata(
|
|
||||||
request.user,stravaid,data,strokedata,
|
|
||||||
source='strava',
|
|
||||||
workoutsource='strava')
|
|
||||||
|
|
||||||
if id==0:
|
|
||||||
messages.error(request,message)
|
|
||||||
|
|
||||||
else:
|
|
||||||
messages.info(request,"imported Strava workout "+str(stravaid))
|
|
||||||
w = Workout.objects.get(id=id)
|
|
||||||
w.uploadedtostrava=stravaid
|
|
||||||
w.save()
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
messages.error(request,"Couldn't import Strava workout "+str(stravaid))
|
messages.error(request,"Couldn't import Strava workout "+str(stravaid))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user