fixes icu
This commit is contained in:
@@ -169,7 +169,10 @@ class IntervalsIntegration(SyncIntegration):
|
|||||||
|
|
||||||
|
|
||||||
def workout_export(self, workout, *args, **kwargs) -> str:
|
def workout_export(self, workout, *args, **kwargs) -> str:
|
||||||
token = self.open()
|
try:
|
||||||
|
token = self.open()
|
||||||
|
except NoTokenError:
|
||||||
|
return 0
|
||||||
dologging('intervals.icu.log', "Exporting workout {id}".format(id=workout.id))
|
dologging('intervals.icu.log', "Exporting workout {id}".format(id=workout.id))
|
||||||
|
|
||||||
filename = self.createworkoutdata(workout)
|
filename = self.createworkoutdata(workout)
|
||||||
@@ -220,6 +223,11 @@ class IntervalsIntegration(SyncIntegration):
|
|||||||
return id
|
return id
|
||||||
|
|
||||||
def get_workout_list(self, *args, **kwargs) -> int:
|
def get_workout_list(self, *args, **kwargs) -> int:
|
||||||
|
try:
|
||||||
|
token = self.open()
|
||||||
|
except NoTokenError:
|
||||||
|
return []
|
||||||
|
|
||||||
url = self.oauth_data['base_url'] + 'athlete/0/activities?'
|
url = self.oauth_data['base_url'] + 'athlete/0/activities?'
|
||||||
startdate = timezone.now() - timedelta(days=30)
|
startdate = timezone.now() - timedelta(days=30)
|
||||||
enddate = timezone.now() + timedelta(days=1)
|
enddate = timezone.now() + timedelta(days=1)
|
||||||
@@ -238,7 +246,7 @@ class IntervalsIntegration(SyncIntegration):
|
|||||||
url += 'oldest=' + startdate.strftime('%Y-%m-%d') + '&newest=' + enddate.strftime('%Y-%m-%d')
|
url += 'oldest=' + startdate.strftime('%Y-%m-%d') + '&newest=' + enddate.strftime('%Y-%m-%d')
|
||||||
headers = {
|
headers = {
|
||||||
'accept': '*/*',
|
'accept': '*/*',
|
||||||
'authorization': 'Bearer ' + self.open(),
|
'authorization': 'Bearer ' + token
|
||||||
}
|
}
|
||||||
|
|
||||||
response = requests.get(url, headers=headers)
|
response = requests.get(url, headers=headers)
|
||||||
@@ -278,7 +286,10 @@ class IntervalsIntegration(SyncIntegration):
|
|||||||
return workouts
|
return workouts
|
||||||
|
|
||||||
def update_workout(self, id, *args, **kwargs) -> int:
|
def update_workout(self, id, *args, **kwargs) -> int:
|
||||||
_ = self.open()
|
try:
|
||||||
|
_ = self.open()
|
||||||
|
except NoTokenError:
|
||||||
|
return 0
|
||||||
r = self.rower
|
r = self.rower
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
@@ -308,8 +319,10 @@ class IntervalsIntegration(SyncIntegration):
|
|||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
w.rpe = data['icu_rpe']
|
w.rpe = data['icu_rpe']
|
||||||
|
if w.rpe is None:
|
||||||
|
w.rpe = 0
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
w.rpe = 0
|
||||||
try:
|
try:
|
||||||
w.is_commute = data['commute']
|
w.is_commute = data['commute']
|
||||||
if w.is_commute is None:
|
if w.is_commute is None:
|
||||||
@@ -387,7 +400,11 @@ class IntervalsIntegration(SyncIntegration):
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
def get_workout(self, id, *args, **kwargs) -> int:
|
def get_workout(self, id, *args, **kwargs) -> int:
|
||||||
_ = self.open()
|
try:
|
||||||
|
_ = self.open()
|
||||||
|
except NoTokenError:
|
||||||
|
return 0
|
||||||
|
|
||||||
r = self.rower
|
r = self.rower
|
||||||
|
|
||||||
do_async = kwargs.get('do_async', True)
|
do_async = kwargs.get('do_async', True)
|
||||||
@@ -506,7 +523,7 @@ class IntervalsIntegration(SyncIntegration):
|
|||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def pair_workout_and_session(w, id):
|
def pair_workout_and_session(self, w, id):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@@ -541,7 +558,11 @@ class IntervalsIntegration(SyncIntegration):
|
|||||||
return super(IntervalsIntegration, self).token_refresh(*args, **kwargs)
|
return super(IntervalsIntegration, self).token_refresh(*args, **kwargs)
|
||||||
|
|
||||||
def get_plannedsessions_list(self, *args, **kwargs):
|
def get_plannedsessions_list(self, *args, **kwargs):
|
||||||
_ = self.open()
|
try:
|
||||||
|
_ = self.open()
|
||||||
|
except NoTokenError:
|
||||||
|
return []
|
||||||
|
|
||||||
r = self.rower
|
r = self.rower
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
@@ -562,7 +583,11 @@ class IntervalsIntegration(SyncIntegration):
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
def update_plannedsession(self, ps, data, *args, **kwargs):
|
def update_plannedsession(self, ps, data, *args, **kwargs):
|
||||||
_ = self.open()
|
try:
|
||||||
|
_ = self.open()
|
||||||
|
except NoTokenError:
|
||||||
|
return 0
|
||||||
|
|
||||||
r = self.rower
|
r = self.rower
|
||||||
|
|
||||||
if data['category'] == 'WORKOUT':
|
if data['category'] == 'WORKOUT':
|
||||||
@@ -584,7 +609,11 @@ class IntervalsIntegration(SyncIntegration):
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
def get_plannedsession(self, id, *args, **kwargs):
|
def get_plannedsession(self, id, *args, **kwargs):
|
||||||
_ = self.open()
|
try:
|
||||||
|
_ = self.open()
|
||||||
|
except NoTokenError:
|
||||||
|
return 0
|
||||||
|
|
||||||
r = self.rower
|
r = self.rower
|
||||||
|
|
||||||
url = self.oauth_data['base_url'] + 'athlete/0/events/' + str(id)
|
url = self.oauth_data['base_url'] + 'athlete/0/events/' + str(id)
|
||||||
@@ -618,7 +647,11 @@ class IntervalsIntegration(SyncIntegration):
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
def plannedsession_create(self, ps, *args, **kwargs):
|
def plannedsession_create(self, ps, *args, **kwargs):
|
||||||
_ = self.open()
|
try:
|
||||||
|
_ = self.open()
|
||||||
|
except NoTokenError:
|
||||||
|
return 0
|
||||||
|
|
||||||
r = self.rower
|
r = self.rower
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
@@ -626,6 +659,7 @@ class IntervalsIntegration(SyncIntegration):
|
|||||||
}
|
}
|
||||||
|
|
||||||
stepstext = ps.steps_intervals()
|
stepstext = ps.steps_intervals()
|
||||||
|
print(stepstext)
|
||||||
|
|
||||||
category = 'WORKOUT'
|
category = 'WORKOUT'
|
||||||
startdate = ps.preferreddate.strftime('%Y-%m-%dT%H:%M:%S')
|
startdate = ps.preferreddate.strftime('%Y-%m-%dT%H:%M:%S')
|
||||||
@@ -671,7 +705,11 @@ class IntervalsIntegration(SyncIntegration):
|
|||||||
return id
|
return id
|
||||||
|
|
||||||
def plannedsession_delete(self, ps, *args, **kwargs):
|
def plannedsession_delete(self, ps, *args, **kwargs):
|
||||||
_ = self.open()
|
try:
|
||||||
|
_ = self.open()
|
||||||
|
except NoTokenError:
|
||||||
|
return 0
|
||||||
|
|
||||||
r = self.rower
|
r = self.rower
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
@@ -750,9 +788,12 @@ class IntervalsIntegration(SyncIntegration):
|
|||||||
ps.sessionvalue = timetarget
|
ps.sessionvalue = timetarget
|
||||||
ps.save()
|
ps.save()
|
||||||
if data['category'].lower() == 'workout':
|
if data['category'].lower() == 'workout':
|
||||||
ps.fitfile = data['fitfile']
|
try:
|
||||||
ps.save()
|
ps.fitfile = data['fitfile']
|
||||||
ps.update_steps()
|
ps.save()
|
||||||
|
ps.update_steps()
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
if data['category'].lower() == 'target':
|
if data['category'].lower() == 'target':
|
||||||
ps.sessiontype = 'cycletarget'
|
ps.sessiontype = 'cycletarget'
|
||||||
ps.sessionvalue = int(data['time_target'])/60.
|
ps.sessionvalue = int(data['time_target'])/60.
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ from rowingdata import rowingdata as rrdata
|
|||||||
import arrow
|
import arrow
|
||||||
import polars as pl
|
import polars as pl
|
||||||
import json
|
import json
|
||||||
|
from rowers import integrations
|
||||||
|
|
||||||
# Python
|
# Python
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
@@ -418,7 +419,7 @@ def add_workouts_plannedsession(ws, ps, r):
|
|||||||
comments.append('Attached workout %s to session' %
|
comments.append('Attached workout %s to session' %
|
||||||
encoder.encode_hex(w.id))
|
encoder.encode_hex(w.id))
|
||||||
if ps.intervals_icu_id:
|
if ps.intervals_icu_id:
|
||||||
integration = integrations.IntervalsIntegration(w.user)
|
integration = integrations.IntervalsIntegration(w.user.user)
|
||||||
integration.pair_workout_and_session(w, ps.intervals_icu_id)
|
integration.pair_workout_and_session(w, ps.intervals_icu_id)
|
||||||
if ps.sessiontype == 'coursetest': # pragma: no cover
|
if ps.sessiontype == 'coursetest': # pragma: no cover
|
||||||
record = CourseTestResult(
|
record = CourseTestResult(
|
||||||
|
|||||||
@@ -137,17 +137,9 @@
|
|||||||
<a class="small"
|
<a class="small"
|
||||||
href="https://intervals.icu/?w={{ ps.preferreddate }}"><i class="fa-kit fa-solid-wave-pulse-circle-check"></i></a>
|
href="https://intervals.icu/?w={{ ps.preferreddate }}"><i class="fa-kit fa-solid-wave-pulse-circle-check"></i></a>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if request.GET.startdate %}
|
|
||||||
<a class="small"
|
|
||||||
href="/rowers/sessions/{{ ps.id }}/tointervals/?next={{ request.path }}?startdate={{ request.GET.startdate }}&enddate={{ request.GET.enddate }}"><i class="fa-solid fa-wave-pulse"></i></a>
|
|
||||||
{% elif request.GET.when %}
|
|
||||||
<a class="small"
|
|
||||||
href="/rowers/sessions/{{ ps.id }}/tointervals/?next={{ request.path }}?when={{ request.GET.when }}"><i class="fa-solid fa-wave-pulse"></i></a>
|
|
||||||
{% else %}
|
|
||||||
<a class="small"
|
<a class="small"
|
||||||
href="/rowers/sessions/{{ ps.id }}/tointervals/?next={{ request.path }}"><i class="fa-solid fa-wave-pulse"></i></a>
|
href="/rowers/sessions/{{ ps.id }}/tointervals/?next={{ request.path }}"><i class="fa-solid fa-wave-pulse"></i></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
|
||||||
</td>
|
</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td> {{ ps.sessionvalue }} </td>
|
<td> {{ ps.sessionvalue }} </td>
|
||||||
|
|||||||
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Binary file not shown.
@@ -737,6 +737,10 @@ def steps_write_fit(steps):
|
|||||||
url = settings.WORKOUTS_FIT_URL+"/tofit"
|
url = settings.WORKOUTS_FIT_URL+"/tofit"
|
||||||
headers = {'Authorization': authorizationstring}
|
headers = {'Authorization': authorizationstring}
|
||||||
|
|
||||||
|
# convert to json, value of keys called wkt_step_name to string
|
||||||
|
for step in steps['steps']:
|
||||||
|
step['wkt_step_name'] = str(step['wkt_step_name'])
|
||||||
|
|
||||||
response = requests.post(url=url, headers=headers, json=steps)
|
response = requests.post(url=url, headers=headers, json=steps)
|
||||||
|
|
||||||
if response.status_code != 200: # pragma: no cover
|
if response.status_code != 200: # pragma: no cover
|
||||||
|
|||||||
@@ -33,7 +33,9 @@ def filmdeaths_view(request):
|
|||||||
|
|
||||||
@login_required()
|
@login_required()
|
||||||
def download_fit(request, filename=''):
|
def download_fit(request, filename=''):
|
||||||
|
print(filename)
|
||||||
pss = PlannedSession.objects.filter(fitfile=filename)
|
pss = PlannedSession.objects.filter(fitfile=filename)
|
||||||
|
print(pss, len(pss))
|
||||||
|
|
||||||
if len(pss) != 1: # pragma: no cover
|
if len(pss) != 1: # pragma: no cover
|
||||||
raise Http404("Could not find the required file")
|
raise Http404("Could not find the required file")
|
||||||
|
|||||||
@@ -1841,6 +1841,8 @@ def plannedsession_clone_view(request, id=0, userid=0):
|
|||||||
if not ps.is_template:
|
if not ps.is_template:
|
||||||
ps.name += ' (copy)'
|
ps.name += ' (copy)'
|
||||||
ps.is_template = False
|
ps.is_template = False
|
||||||
|
ps.intervals_icu_id = None
|
||||||
|
ps.rojabo_id = 0
|
||||||
|
|
||||||
deltadays = ps.preferreddate-ps.startdate
|
deltadays = ps.preferreddate-ps.startdate
|
||||||
|
|
||||||
@@ -2057,11 +2059,6 @@ def plannedsession_tointervals_view(request, id=0):
|
|||||||
|
|
||||||
r = getrequestplanrower(request)
|
r = getrequestplanrower(request)
|
||||||
|
|
||||||
startdate, enddate = get_dates_timeperiod(request)
|
|
||||||
startdate = startdate.date()
|
|
||||||
enddate = enddate.date()
|
|
||||||
|
|
||||||
|
|
||||||
ps = get_object_or_404(PlannedSession, pk=id)
|
ps = get_object_or_404(PlannedSession, pk=id)
|
||||||
|
|
||||||
intervals = IntervalsIntegration(request.user)
|
intervals = IntervalsIntegration(request.user)
|
||||||
@@ -2077,13 +2074,14 @@ def plannedsession_tointervals_view(request, id=0):
|
|||||||
url = reverse(plannedsession_view, kwargs={'userid': r.user.id,
|
url = reverse(plannedsession_view, kwargs={'userid': r.user.id,
|
||||||
'id': ps.id, })
|
'id': ps.id, })
|
||||||
|
|
||||||
startdatestring = startdate.strftime('%Y-%m-%d')
|
thenext = request.GET.get('next', url)
|
||||||
enddatestring = enddate.strftime('%Y-%m-%d')
|
|
||||||
url += '?when='+startdatestring+'/'+enddatestring
|
|
||||||
|
|
||||||
next = request.GET.get('next', url)
|
# add ?startdate=startdate&enddate=enddate to url, with startdate ps.startdate and enddate ps.enddate
|
||||||
|
startdate = ps.startdate.strftime('%Y-%m-%d')
|
||||||
|
enddate = ps.enddate.strftime('%Y-%m-%d')
|
||||||
|
url += '?startdate='+startdate+'&enddate='+enddate
|
||||||
|
|
||||||
return HttpResponseRedirect(next)
|
return HttpResponseRedirect(thenext)
|
||||||
|
|
||||||
|
|
||||||
@permission_required('plannedsession.change_session', fn=get_session_by_pk, raise_exception=True)
|
@permission_required('plannedsession.change_session', fn=get_session_by_pk, raise_exception=True)
|
||||||
@@ -2114,7 +2112,7 @@ def plannedsession_togarmin_view(request, id=0):
|
|||||||
|
|
||||||
startdatestring = startdate.strftime('%Y-%m-%d')
|
startdatestring = startdate.strftime('%Y-%m-%d')
|
||||||
enddatestring = enddate.strftime('%Y-%m-%d')
|
enddatestring = enddate.strftime('%Y-%m-%d')
|
||||||
url += '?when='+startdatestring+'/'+enddatestring
|
url += '?startdate='+startdatestring+'&enddate='+enddatestring
|
||||||
|
|
||||||
next = request.GET.get('next', url)
|
next = request.GET.get('next', url)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user