warmingup/cd
This commit is contained in:
@@ -203,20 +203,32 @@ class IntervalsIntegration(SyncIntegration):
|
||||
return 0
|
||||
|
||||
id = response.json()['id']
|
||||
workout.uploadedtointervals = id
|
||||
workout.save()
|
||||
|
||||
os.remove(filename)
|
||||
|
||||
# set workout type to workouttype
|
||||
url = "https://intervals.icu/api/v1/activity/{activityid}".format(activityid=id)
|
||||
|
||||
|
||||
thetype = mytypes.intervalsmapping[workout.workouttype]
|
||||
response = requests.put(url, headers=headers, json={'type': thetype})
|
||||
jsondict = {'type': thetype}
|
||||
subtype = w.sub_type
|
||||
if subtype:
|
||||
jsondict['sub_type'] = subtype
|
||||
|
||||
jsondict['icu_rpe'] = workout.rpe
|
||||
jsondict['commute'] = workout.is_commute
|
||||
if workout.plannedsession:
|
||||
jsondict['paired_event_id'] = workout.plannedsession.intervals_icu_id
|
||||
|
||||
|
||||
response = requests.put(url, headers=headers, json=jsondict)
|
||||
|
||||
if response.status_code not in [200, 201]:
|
||||
return 0
|
||||
|
||||
workout.uploadedtointervals = id
|
||||
workout.save()
|
||||
|
||||
os.remove(filename)
|
||||
|
||||
dologging('intervals.icu.log', "Exported workout {id}".format(id=workout.id))
|
||||
|
||||
|
||||
@@ -3718,6 +3718,13 @@ rpechoices = (
|
||||
(10, '10 Max Effort (You can barely remember your name, you would rather rip out your toenails than go through this)')
|
||||
)
|
||||
|
||||
subcategories = (
|
||||
(None, "None"),
|
||||
("Race", "Race"),
|
||||
("Commute", "Commute"),
|
||||
("Warming Up", "Warming Up"),
|
||||
("Cooling Down", "Cooling Down")
|
||||
)
|
||||
|
||||
class Workout(models.Model):
|
||||
workouttypes = mytypes.workouttypes
|
||||
@@ -3770,6 +3777,8 @@ class Workout(models.Model):
|
||||
verbose_name='Rate of Perceived Exertion')
|
||||
|
||||
is_commute = models.BooleanField(default=False)
|
||||
is_race = models.BooleanField(default=False)
|
||||
sub_type = models.CharField(default=None, null=True, blank=True, choices=subcategories, max_length=250)
|
||||
|
||||
weightcategory = models.CharField(
|
||||
default="hwt",
|
||||
@@ -4624,6 +4633,7 @@ class WorkoutForm(ModelForm):
|
||||
'duration',
|
||||
'distance',
|
||||
'workouttype',
|
||||
'sub_type',
|
||||
'boattype',
|
||||
'boatname',
|
||||
'seatnumber',
|
||||
@@ -4636,6 +4646,7 @@ class WorkoutForm(ModelForm):
|
||||
'rankingpiece',
|
||||
'duplicate',
|
||||
'is_commute',
|
||||
'is_race',
|
||||
'plannedsession']
|
||||
widgets = {
|
||||
'date': AdminDateWidget(),
|
||||
|
||||
@@ -3599,6 +3599,7 @@ def handle_intervals_getworkout(rower, intervalstoken, workoutid, debug=False, *
|
||||
return 0
|
||||
|
||||
data = response.json()
|
||||
|
||||
try:
|
||||
title = data['name']
|
||||
except KeyError:
|
||||
@@ -3621,6 +3622,21 @@ def handle_intervals_getworkout(rower, intervalstoken, workoutid, debug=False, *
|
||||
except KeyError:
|
||||
is_commute = False
|
||||
|
||||
|
||||
try:
|
||||
subtype = data['sub_type']
|
||||
if subtype is not None:
|
||||
subtype = subtype.capitalize()
|
||||
except KeyError:
|
||||
subtype = None
|
||||
|
||||
try:
|
||||
is_race = data['race']
|
||||
if is_race is None:
|
||||
is_race = False
|
||||
except KeyError:
|
||||
is_race = False
|
||||
|
||||
url = "https://intervals.icu/api/v1/activity/{workoutid}/fit-file".format(workoutid=workoutid)
|
||||
|
||||
response = requests.get(url, headers=headers)
|
||||
@@ -3667,7 +3683,14 @@ def handle_intervals_getworkout(rower, intervalstoken, workoutid, debug=False, *
|
||||
if is_commute:
|
||||
for w in ws:
|
||||
w.is_commute = True
|
||||
w.sub_type = "Commute"
|
||||
w.save()
|
||||
for w in ws:
|
||||
w.sub_type = subtype
|
||||
w.save()
|
||||
if is_race:
|
||||
w.is_race = True
|
||||
w.save()
|
||||
if ws.count() > 0:
|
||||
pss = PlannedSession.objects.filter(rower=rower,intervals_icu_id=paired_event_id)
|
||||
if pss.count() > 0:
|
||||
|
||||
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Binary file not shown.
@@ -2080,10 +2080,12 @@ def workouts_bulk_actions(request):
|
||||
elif action == 'set commute':
|
||||
for w in workouts:
|
||||
w.is_commute = True
|
||||
w.sub_type = "Commute"
|
||||
w.save()
|
||||
elif action == 'unset commute':
|
||||
for w in workouts:
|
||||
w.is_commute = False
|
||||
w.sub_type = None
|
||||
w.save()
|
||||
elif action == 'set public':
|
||||
for w in workouts:
|
||||
@@ -4503,6 +4505,8 @@ def workout_edit_view(request, id=0, message="", successmessage=""):
|
||||
newdragfactor = form.cleaned_data['dragfactor']
|
||||
thetimezone = form.cleaned_data['timezone']
|
||||
is_commute = form.cleaned_data['is_commute']
|
||||
is_race = form.cleaned_data['is_race']
|
||||
subtype = form.cleaned_data['sub_type']
|
||||
try:
|
||||
rpe = form.cleaned_data['rpe']
|
||||
if not rpe: # pragma: no cover
|
||||
@@ -4523,7 +4527,11 @@ def workout_edit_view(request, id=0, message="", successmessage=""):
|
||||
seatnumber = form.cleaned_data.get('seatnumber', 1)
|
||||
boatname = form.cleaned_data.get('boatname', '')
|
||||
empowerside = form.cleaned_data.get('empowerside','port')
|
||||
|
||||
|
||||
if is_race and subtype is None:
|
||||
subtype = "Race"
|
||||
elif is_commute and subtype is None:
|
||||
subtype = "Commute"
|
||||
|
||||
if private:
|
||||
privacy = 'hidden'
|
||||
@@ -4581,6 +4589,8 @@ def workout_edit_view(request, id=0, message="", successmessage=""):
|
||||
row.empowerside = empowerside
|
||||
row.seatnumber = seatnumber
|
||||
row.is_commute = is_commute
|
||||
row.is_race = is_race
|
||||
row.sub_type = subtype
|
||||
|
||||
dragchanged = False
|
||||
if newdragfactor != row.dragfactor: # pragma: no cover
|
||||
|
||||
Reference in New Issue
Block a user