first implementation
This commit is contained in:
@@ -306,8 +306,29 @@ class IntervalsIntegration(SyncIntegration):
|
||||
w.workouttype = mytypes.intervalsmappinginv[data['type']]
|
||||
except KeyError:
|
||||
pass
|
||||
try:
|
||||
w.rpe = data['icu_rpe']
|
||||
except KeyError:
|
||||
pass
|
||||
try:
|
||||
w.is_commute = data['commute']
|
||||
if w.is_commute is None:
|
||||
w.is_commute = False
|
||||
except KeyError:
|
||||
w.is_commute = False
|
||||
|
||||
w.save()
|
||||
|
||||
try:
|
||||
paired_session_icu_id = data['paired_event_id']
|
||||
pss = PlannedSession.objects.filter(intervals_icu_id=paired_session_icu_id, rower=self.rower)
|
||||
if pss.count() > 0:
|
||||
for ps in pss:
|
||||
w.plannedsession = ps
|
||||
w.save()
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
# we stop here now
|
||||
return 1
|
||||
|
||||
@@ -406,6 +427,18 @@ class IntervalsIntegration(SyncIntegration):
|
||||
except KeyError:
|
||||
title = 'Intervals workout'
|
||||
|
||||
try:
|
||||
rpe = data['icu_rpe']
|
||||
except KeyError:
|
||||
rpe = 0
|
||||
|
||||
try:
|
||||
is_commute = data['commute']
|
||||
if is_commute is None:
|
||||
is_commute = False
|
||||
except KeyError:
|
||||
is_commute = False
|
||||
|
||||
try:
|
||||
workouttype = mytypes.intervalsmappinginv[data['type']]
|
||||
except KeyError:
|
||||
@@ -443,13 +476,38 @@ class IntervalsIntegration(SyncIntegration):
|
||||
'file': fit_filename,
|
||||
'intervalsid': id,
|
||||
'title': title,
|
||||
'rpe': 0,
|
||||
'rpe': rpe,
|
||||
'notes': '',
|
||||
'offline': False,
|
||||
}
|
||||
|
||||
url = UPLOAD_SERVICE_URL
|
||||
return handle_request_post(url, uploadoptions)
|
||||
handle_request_post(url, uploadoptions)
|
||||
|
||||
try:
|
||||
pair_id = data['paired_event_id']
|
||||
pss = PlannedSession.objects.filter(intervals_icu_id=pair_id, rower=r)
|
||||
ws = Workout.objects.filter(uploadedtointervals=id)
|
||||
if is_commute:
|
||||
for w in ws:
|
||||
w.is_commute = True
|
||||
w.save()
|
||||
if pss.count() > 0:
|
||||
for ps in pss:
|
||||
for w in ws:
|
||||
w.plannedsession = ps
|
||||
w.save()
|
||||
except KeyError:
|
||||
pass
|
||||
except PlannedSession.DoesNotExist:
|
||||
pass
|
||||
except Workout.DoesNotExist:
|
||||
pass
|
||||
|
||||
return 1
|
||||
|
||||
def pair_workout_and_session(w, id):
|
||||
pass
|
||||
|
||||
|
||||
def get_workouts(self, *args, **kwargs):
|
||||
|
||||
@@ -3740,6 +3740,8 @@ class Workout(models.Model):
|
||||
rpe = models.IntegerField(default=0, blank=True, choices=rpechoices,
|
||||
verbose_name='Rate of Perceived Exertion')
|
||||
|
||||
is_commute = models.BooleanField(default=False)
|
||||
|
||||
weightcategory = models.CharField(
|
||||
default="hwt",
|
||||
max_length=10,
|
||||
@@ -4601,6 +4603,7 @@ class WorkoutForm(ModelForm):
|
||||
'notes',
|
||||
'rankingpiece',
|
||||
'duplicate',
|
||||
'is_commute',
|
||||
'plannedsession']
|
||||
widgets = {
|
||||
'date': AdminDateWidget(),
|
||||
|
||||
@@ -417,6 +417,9 @@ def add_workouts_plannedsession(ws, ps, r):
|
||||
result += 1
|
||||
comments.append('Attached workout %s to session' %
|
||||
encoder.encode_hex(w.id))
|
||||
if ps.intervals_icu_id:
|
||||
integration = integrations.IntervalsIntegration(w.user)
|
||||
integration.pair_workout_and_session(w, ps.intervals_icu_id)
|
||||
if ps.sessiontype == 'coursetest': # pragma: no cover
|
||||
record = CourseTestResult(
|
||||
userid=w.user.id,
|
||||
|
||||
@@ -3586,6 +3586,18 @@ def handle_intervals_getworkout(rower, intervalstoken, workoutid, debug=False, *
|
||||
except KeyError:
|
||||
workouttype = 'water'
|
||||
|
||||
try:
|
||||
rpe = data['icu_rpe']
|
||||
except KeyError:
|
||||
rpe = 0
|
||||
|
||||
try:
|
||||
is_commute = data['commute']
|
||||
if is_commute is None:
|
||||
is_commute = False
|
||||
except KeyError:
|
||||
is_commute = False
|
||||
|
||||
url = "https://intervals.icu/api/v1/activity/{workoutid}/fit-file".format(workoutid=workoutid)
|
||||
|
||||
response = requests.get(url, headers=headers)
|
||||
@@ -3618,7 +3630,7 @@ def handle_intervals_getworkout(rower, intervalstoken, workoutid, debug=False, *
|
||||
'file': fit_filename,
|
||||
'intervalsid': workoutid,
|
||||
'title': title,
|
||||
'rpe': 0,
|
||||
'rpe': rpe,
|
||||
'notes': '',
|
||||
'offline': False,
|
||||
}
|
||||
@@ -3626,6 +3638,27 @@ def handle_intervals_getworkout(rower, intervalstoken, workoutid, debug=False, *
|
||||
url = UPLOAD_SERVICE_URL
|
||||
handle_request_post(url, uploadoptions)
|
||||
|
||||
try:
|
||||
paired_event_id = data['paired_event_id']
|
||||
ws = Workout.objects.filter(uploadedtointervals=workoutid)
|
||||
if is_commute:
|
||||
for w in ws:
|
||||
w.is_commute = True
|
||||
w.save()
|
||||
if ws.count() > 0:
|
||||
pss = PlannedSession.objects.filter(rower=rower,intervals_icu_id=paired_event_id)
|
||||
if pss.count() > 0:
|
||||
for ps in pss:
|
||||
for w in ws:
|
||||
w.plannedsession = ps
|
||||
w.save()
|
||||
except KeyError:
|
||||
pass
|
||||
except Workout.DoesNotExist:
|
||||
pass
|
||||
except PlannedSession.DoesNotExist:
|
||||
pass
|
||||
|
||||
return 1
|
||||
|
||||
@app.task
|
||||
|
||||
@@ -4455,6 +4455,7 @@ def workout_edit_view(request, id=0, message="", successmessage=""):
|
||||
notes = form.cleaned_data['notes']
|
||||
newdragfactor = form.cleaned_data['dragfactor']
|
||||
thetimezone = form.cleaned_data['timezone']
|
||||
is_commute = form.cleaned_data['is_commute']
|
||||
try:
|
||||
rpe = form.cleaned_data['rpe']
|
||||
if not rpe: # pragma: no cover
|
||||
@@ -4532,6 +4533,7 @@ def workout_edit_view(request, id=0, message="", successmessage=""):
|
||||
row.boatname = boatname
|
||||
row.empowerside = empowerside
|
||||
row.seatnumber = seatnumber
|
||||
row.is_commute = is_commute
|
||||
|
||||
dragchanged = False
|
||||
if newdragfactor != row.dragfactor: # pragma: no cover
|
||||
|
||||
Reference in New Issue
Block a user