Private
Public Access
1
0

warmingup/cd

This commit is contained in:
2025-02-16 19:13:19 +01:00
parent 1c12ebb162
commit 8121b77ba7
5 changed files with 62 additions and 6 deletions

View File

@@ -203,20 +203,32 @@ class IntervalsIntegration(SyncIntegration):
return 0 return 0
id = response.json()['id'] id = response.json()['id']
workout.uploadedtointervals = id
workout.save()
os.remove(filename)
# set workout type to workouttype # set workout type to workouttype
url = "https://intervals.icu/api/v1/activity/{activityid}".format(activityid=id) url = "https://intervals.icu/api/v1/activity/{activityid}".format(activityid=id)
thetype = mytypes.intervalsmapping[workout.workouttype] 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]: if response.status_code not in [200, 201]:
return 0 return 0
workout.uploadedtointervals = id
workout.save()
os.remove(filename)
dologging('intervals.icu.log', "Exported workout {id}".format(id=workout.id)) dologging('intervals.icu.log', "Exported workout {id}".format(id=workout.id))

View File

@@ -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)') (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): class Workout(models.Model):
workouttypes = mytypes.workouttypes workouttypes = mytypes.workouttypes
@@ -3770,6 +3777,8 @@ class Workout(models.Model):
verbose_name='Rate of Perceived Exertion') verbose_name='Rate of Perceived Exertion')
is_commute = models.BooleanField(default=False) 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( weightcategory = models.CharField(
default="hwt", default="hwt",
@@ -4624,6 +4633,7 @@ class WorkoutForm(ModelForm):
'duration', 'duration',
'distance', 'distance',
'workouttype', 'workouttype',
'sub_type',
'boattype', 'boattype',
'boatname', 'boatname',
'seatnumber', 'seatnumber',
@@ -4636,6 +4646,7 @@ class WorkoutForm(ModelForm):
'rankingpiece', 'rankingpiece',
'duplicate', 'duplicate',
'is_commute', 'is_commute',
'is_race',
'plannedsession'] 'plannedsession']
widgets = { widgets = {
'date': AdminDateWidget(), 'date': AdminDateWidget(),

View File

@@ -3599,6 +3599,7 @@ def handle_intervals_getworkout(rower, intervalstoken, workoutid, debug=False, *
return 0 return 0
data = response.json() data = response.json()
try: try:
title = data['name'] title = data['name']
except KeyError: except KeyError:
@@ -3621,6 +3622,21 @@ def handle_intervals_getworkout(rower, intervalstoken, workoutid, debug=False, *
except KeyError: except KeyError:
is_commute = False 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) url = "https://intervals.icu/api/v1/activity/{workoutid}/fit-file".format(workoutid=workoutid)
response = requests.get(url, headers=headers) response = requests.get(url, headers=headers)
@@ -3667,6 +3683,13 @@ def handle_intervals_getworkout(rower, intervalstoken, workoutid, debug=False, *
if is_commute: if is_commute:
for w in ws: for w in ws:
w.is_commute = True 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() w.save()
if ws.count() > 0: if ws.count() > 0:
pss = PlannedSession.objects.filter(rower=rower,intervals_icu_id=paired_event_id) pss = PlannedSession.objects.filter(rower=rower,intervals_icu_id=paired_event_id)

Binary file not shown.

View File

@@ -2080,10 +2080,12 @@ def workouts_bulk_actions(request):
elif action == 'set commute': elif action == 'set commute':
for w in workouts: for w in workouts:
w.is_commute = True w.is_commute = True
w.sub_type = "Commute"
w.save() w.save()
elif action == 'unset commute': elif action == 'unset commute':
for w in workouts: for w in workouts:
w.is_commute = False w.is_commute = False
w.sub_type = None
w.save() w.save()
elif action == 'set public': elif action == 'set public':
for w in workouts: for w in workouts:
@@ -4503,6 +4505,8 @@ def workout_edit_view(request, id=0, message="", successmessage=""):
newdragfactor = form.cleaned_data['dragfactor'] newdragfactor = form.cleaned_data['dragfactor']
thetimezone = form.cleaned_data['timezone'] thetimezone = form.cleaned_data['timezone']
is_commute = form.cleaned_data['is_commute'] is_commute = form.cleaned_data['is_commute']
is_race = form.cleaned_data['is_race']
subtype = form.cleaned_data['sub_type']
try: try:
rpe = form.cleaned_data['rpe'] rpe = form.cleaned_data['rpe']
if not rpe: # pragma: no cover if not rpe: # pragma: no cover
@@ -4524,6 +4528,10 @@ def workout_edit_view(request, id=0, message="", successmessage=""):
boatname = form.cleaned_data.get('boatname', '') boatname = form.cleaned_data.get('boatname', '')
empowerside = form.cleaned_data.get('empowerside','port') 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: if private:
privacy = 'hidden' privacy = 'hidden'
@@ -4581,6 +4589,8 @@ def workout_edit_view(request, id=0, message="", successmessage=""):
row.empowerside = empowerside row.empowerside = empowerside
row.seatnumber = seatnumber row.seatnumber = seatnumber
row.is_commute = is_commute row.is_commute = is_commute
row.is_race = is_race
row.sub_type = subtype
dragchanged = False dragchanged = False
if newdragfactor != row.dragfactor: # pragma: no cover if newdragfactor != row.dragfactor: # pragma: no cover